Practice
一:Adjust the “brightness” and “contrast” of rice.png and display it on the screen(改变米图的亮度与对比度并展示)
%亮度的改变通过增加灰度图的值
%对比度的增加可以共同乘一个大于1的数值
%使用两个for循环,可以提前建立两个zeros矩阵可减少运算时间
I=imread(‘rice.png’);
subplot(1,3,1);imshow(I)%显示原图
for i=size(I,1)
for j=size(I,2)
I1(i,j)=I(i,j)+50;%增加亮度
I2(i,j)=I(i,j).*1.3;%增加对比度
end
end
subplot(1,3,2);imshow(I1)%绘制增加亮度后的图
subplot(1,3,3);imshow(I2)%绘制增加对比度后的图
二:Plot the histograms of the images before and after the “brightness” and “contrast” adjustment for rice.png(绘制原图直方图与增加对比度与亮度后的直方图)
%直接使用MATLAB内置的function:imhist()即可
imhist(I);
imhist(I1);
imhist(I2);
三:Write your own equalization function, try it on pout.tif, and display it on the screen(书写自己的直方图均衡化算法,将图片均衡化后显示)
%直方图均衡化的核心即为将pixels的分布扩展既符合它本身的分布函数又扩展到整个histogram上
%因此首先求出其 密度函数与分布函数,然后将分布函数乘256,这样就为扩展后的灰度值分布,再找到每个灰度值代表数为多少,一一对应过来(此处使用https://blog.youkuaiyun.com/yutong5818/article/details/80304012中的方法,因为本人写不出来,也是学习的)
MatLab学习作业之数字图像处理上(台大郭彦甫)
最新推荐文章于 2023-07-04 17:33:25 发布