数字图像处理实验报告(全答案).. 下载本文

内容发布更新时间 : 2024/4/24 5:03:28星期一 下面是文章的全部内容请认真阅读。

四、实验内容

1、对一幅图像进行2倍、4倍、8倍和16倍减采样,显示结果。 a=imread('f:/1.jpg'); b=rgb2gray(a); for m=1:4 figure

[width,height]=size(b);

quartimage=zeros(floor(width/(m)),floor(height/(2*m))); k=1; n=1;

for i=1:(m):width for j=1:(2*m):height quartimage(k,n)=b(i,j); n=n+1; end k=k+1; n=1; end

imshow(uint8(quartimage)); End

2、显示一幅灰度图像a,改变图像亮度使其整体变暗得到图像b,显示两幅图像的直方图。

a=imread('f:\\lena_color.png') c=rgb2gray(a) b=c-46

subplot(2,1,1);imhist(c);title('原图像') subplot(2,1,2);imhist(b);title('变暗后的图像')