首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MATLAB图像处理:我的直方图的最后一页

MATLAB图像处理:我的直方图的最后一页
EN

Stack Overflow用户
提问于 2020-01-19 22:21:55
回答 1查看 114关注 0票数 1

我使用了不调整功能来降低我原来图像的对比度。然而,当我生成这张低对比度图像的直方图时,我注意到最后一个垃圾桶会上升,而不会反映原始图像的直方图。我很肯定,当你降低对比度,垃圾箱高度相对相同,但直方图作为一个整体变得更窄。但在这种情况下,虽然它变得更窄,最后一个垃圾箱看起来比它应该要高得多。我已经附上了我的代码和其他相关的图片。

代码语言:javascript
复制
im = imread('elephant.jpg');

%converts image to grayscale and displays it
im_gray = rgb2gray(im);
figure; 
imshow(im_gray)
title ('Original Gray-scale Image');

%displays the histogram of the grayscale image
figure; 
imhist(im_gray);
axis([0 255 0 22920])
title ('Histogram of the Original Gray-scale Image')
xlabel ('Pixel Value (Gray-level), ai')
ylabel ('Number of Pixels, Ni')

%lowers the contrast of original image --> deteriorated image
J = imadjust(im_gray,[0 0.5], [0.3 0.5]);
figure;
imshow(J);
title ('Deteriorated Image')

%displays histogram of the deteriorated image
figure;
imhist(J);
axis([0 255 0 489000])
title ('Histogram of the Deteriorated Image')
xlabel ('Pixel Value (Gray-level), ai')
ylabel ('Number of Pixels, Ni')

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-19 23:35:07

因为imadjust正在夹紧象素的范围,所以最后一次“腾飞”。

命令:J = imadjust(im_gray,[0 0.5], [0.3 0.5]);

获取0.5 (高于128)的所有im_gray值,并将其替换为0.5 ( uint8范围内的128值)。

不调整文档有点不清楚:

J=不调整(I,low_in high_in,low_out high_out)将I中的强度值映射到J中的新值,从而使low_in和high_in之间的值映射到low_out和high_out之间的值。

它没有说明在范围[low_in high_in]之外的值发生了什么变化。

你可以从前一句理解它:

J=不调整(i,low_in high_in)将I中的强度值映射到J中的新值,从而使low_in和high_in之间的值映射为0到1之间的值。

  • low_in下面的所有值都映射到low_out
  • high_in上的所有值都映射到high_out

im_gray中,所有高于0.5 (高于128个)的值都映射为0.5。

由于im_gray在128个以上有许多像素,所以J有许多像素等于 128。

直方图的中心框数大约占总像素的一半。

您可以使用sum(J(:) == 128)进行检查。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59814932

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档