2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > MatLab 数字图像处理实验 图像增强

MatLab 数字图像处理实验 图像增强

时间:2023-12-22 00:58:36

相关推荐

MatLab 数字图像处理实验 图像增强

实验内容

(1)对曝光不足的图像采用灰度线性变换对图像每一个像素灰度做线性拉伸。

close allclear allI = im2double(imread('D:\figure51.jpg'));a = 1.2;b = -150;I2 = a.*I+b/255;figure;subplot(1,2,1);imshow(I);xlabel('原图');subplot(1,2,2);imshow(I2);xlabel('a=1.2 b=-150 增强图');

(2)利用空间域平滑滤波器对图像进行平滑。

close allclear allI = imread('D:\lena.jpg');I_noise = double(imnoise(I,'gaussian',0.05));I_smoothed3 = imfilter(I_noise,fspecial('average',3));I_smoothed5 = imfilter(I_noise,fspecial('average',5));I_smoothed7 = imfilter(I_noise,fspecial('average',7));subplot(2,3,1);imshow(I);xlabel('原图');subplot(2,3,2);imshow(I_noise,[]);xlabel('加入高斯噪声');subplot(2,3,3);imshow(I_smoothed3,[]);xlabel('3x3邻域平滑');subplot(2,3,4);imshow(I_smoothed5,[]);xlabel('5x5邻域平滑');subplot(2,3,5);imshow(I_smoothed7,[]);xlabel('7x7邻域平滑');

(3)利用Prewitt、Sobel对图像进行锐化。

close allclear allI = imread('D:\lena.jpg');I2 = imfilter(I,fspecial('Prewitt'));I3 = imfilter(I,fspecial('Sobel'));subplot(1,3,1);imshow(I);xlabel('原图');subplot(1,3,2);imshow(I2);xlabel('Prewitt锐化后的图像');subplot(1,3,3);imshow(I2);xlabel('Sobel锐化后的图像');

(4)利用高斯低通滤波对图像进行平滑。

I = imread('D:/lena.jpg');IO1 = G(I,10);IO2 = G(I,20);IO3 = G(I,40);subplot(2,2,1);imshow(I);xlabel('初始图像');subplot(2,2,2);imshow(IO1,[]);xlabel('sig^2=100');subplot(2,2,3);imshow(IO2,[]);xlabel('sig^2=400');subplot(2,2,4);imshow(IO3,[]);xlabel('sig^2=1600');function[I3]=G(I,sig)I1 = fftshift(fft2(I));[M,N] = size(I1);n=2;n1=floor(M/2);n2=floor(N/2);for i=1:Mfor j=1:Nd=sqrt((i-n1)^2+(j-n2)^2);H=exp(-((d^2/(2*sig^2))));I2(i,j)=H*I1(i,j);endendI2=ifftshift(I2);I3=real(ifft2(I2));end

参考:/uchihalyn/article/details/104593878

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。