关闭

数字图像处理之点运算

标签: 图像处理imageimgraphinput
1998人阅读 评论(0) 收藏 举报
分类:
-------------------------------------------------------------------------------------------------------------------
灰度直方图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');
      

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:535670次
    • 积分:8867
    • 等级:
    • 排名:第2142名
    • 原创:339篇
    • 转载:19篇
    • 译文:1篇
    • 评论:152条
    最新评论