数字图像处理之点运算
生活随笔
收集整理的這篇文章主要介紹了
数字图像处理之点运算
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
-------------------------------------------------------------------------------------------------------------------
灰度直方圖imhist
IMHIST(I) displays a histogram for the intensity image I whose number of
??? bins are specified by the image type.? If I is a grayscale image, IMHIST
??? uses 256 bins as a default value. If I is a binary image, IMHIST uses
??? only 2 bins.
i=imread('lena.gif'); %灰度圖像,128x128 imshow(i);title('source');%顯示源圖像 figure; imhist(i);title('graph');%顯示灰度直方圖
直方圖的峰值位置說明了圖像總體上的亮暗,如果圖像較暗,峰值靠左;反之靠右。
另外:
在workspace中顯示i=128x128,即單通道128x128.觀察圖像數據如下
而如果是彩色rgb圖像如
i=imread('lena.jpg'); %圖像,512x512x3 imshow(i);title('source');%顯示源圖像
雙擊i也可查看每個像素點的值
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
灰度閾值變換im2bw
?IM2BW Convert image to binary image by thresholding.
??? IM2BW produces binary images from indexed, intensity, or RGB
??? images. To do this, it converts the input image to grayscale
??? format (if it is not already an intensity image), and then
??? converts this grayscale image to binary by thresholding.
rgb=imread('lena.jpg'); imshow(rgb);title('原圖像');figure; i=rgb2gray(rgb);%先轉化成灰度圖像,也可以不轉,因為im2bw會自動轉 subplot(1,3,1);imshow(i);title('灰度圖像');threshold=graythresh(i); bw1=im2bw(i,threshold); subplot(1,3,2);imshow(bw1);title('2值圖像,自動選擇閾值');bw2=im2bw(i,130/255); subplot(1,3,3);imshow(bw2);title('2值圖像,閾值130');??????
灰度直方圖imhist
IMHIST(I) displays a histogram for the intensity image I whose number of
??? bins are specified by the image type.? If I is a grayscale image, IMHIST
??? uses 256 bins as a default value. If I is a binary image, IMHIST uses
??? only 2 bins.
i=imread('lena.gif'); %灰度圖像,128x128 imshow(i);title('source');%顯示源圖像 figure; imhist(i);title('graph');%顯示灰度直方圖
直方圖的峰值位置說明了圖像總體上的亮暗,如果圖像較暗,峰值靠左;反之靠右。
另外:
在workspace中顯示i=128x128,即單通道128x128.觀察圖像數據如下
而如果是彩色rgb圖像如
i=imread('lena.jpg'); %圖像,512x512x3 imshow(i);title('source');%顯示源圖像
雙擊i也可查看每個像素點的值
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
灰度閾值變換im2bw
?IM2BW Convert image to binary image by thresholding.
??? IM2BW produces binary images from indexed, intensity, or RGB
??? images. To do this, it converts the input image to grayscale
??? format (if it is not already an intensity image), and then
??? converts this grayscale image to binary by thresholding.
rgb=imread('lena.jpg'); imshow(rgb);title('原圖像');figure; i=rgb2gray(rgb);%先轉化成灰度圖像,也可以不轉,因為im2bw會自動轉 subplot(1,3,1);imshow(i);title('灰度圖像');threshold=graythresh(i); bw1=im2bw(i,threshold); subplot(1,3,2);imshow(bw1);title('2值圖像,自動選擇閾值');bw2=im2bw(i,130/255); subplot(1,3,3);imshow(bw2);title('2值圖像,閾值130');??????
轉載于:https://www.cnblogs.com/-song/archive/2012/03/25/3331886.html
總結
以上是生活随笔為你收集整理的数字图像处理之点运算的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数字图像基础,论坛,算法库matlab,
- 下一篇: 数字图像处理之几何变换