rgb1=imread('luoye.jpg')%自己随便找的图
hsi1=rgb2hsi(rgb1)%rgb2hsi函数软件中没有,自己写个function函数,网上一大堆
S=hsi1(:,:,2)
H=hsi1(:,:,1)
I=hsi1(:,:,3)
subplot(2,2,1)imshow(hsi1)title('叠加的HSI')
subplot(2,2,2)imshow(S)title('S分量')
subplot(2,2,3)imshow(H)title('H分量')
subplot(2,2,4)imshow(I)title('I分量')
%% 这么基本的图像处理问题都不会,上课干啥!!!我就现学现卖了。%% 2 去雾
% he5.png类似,把下面代码的he2换成he5即可。
he2 = imread('he2.png')% 读图
HSI = rgb2hsv(he2)%转换到hsi空间
I = HSI(:,:,3) % 获得I分量
Ieq = histeq(I,256) % 直方图均衡化
HSI(:,:,3) = Ieq
he2eq = hsv2rgb(HSI) % 转换到rgb空间
figure
subplot(221)imshow(he2)title('he2原图')
subplot(222)imhist(I,256)title('he2原图I分量直方图')
subplot(223)imhist(Ieq,256)title('he2去雾I分量直方图')
subplot(224)imshow(he2eq)title('he2去雾')
%% 3 时域滤波
lena = imread('lena.tif')
lena_noise = imnoise(lena,'salt &pepper',0.05)% 加<a href="https://www.baidu.com/s?wd=%E6%A4%92%E7%9B%90%E5%99%AA%E5%A3%B0&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1d9mynLnvRvP1b4uH7hrymd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHfYrj0vnH6dn16snWbkPWRYn0" target="_blank" class="baidu-highlight">椒盐噪声</a>
lena_filter = medfilt2(lena_noise,[5,5]) % 中值滤波
cm = imread('cameraman.tif')
cm_noise = imnoise(cm,'gaussian',0,0.003) % 加<a href="https://www.baidu.com/s?wd=%E9%AB%98%E6%96%AF%E5%99%AA%E5%A3%B0&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1d9mynLnvRvP1b4uH7hrymd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHfYrj0vnH6dn16snWbkPWRYn0" target="_blank" class="baidu-highlight">高斯噪声</a>
h = fspecial('average')
cm_filter = imfilter(cm_noise,h) % 均值滤波
figure
subplot(231)imshow(lena)title('lena原图')
subplot(232)imshow(lena_noise)title('lena加噪图')
subplot(233)imshow(lena_filter)title('lena去噪')
subplot(234)imshow(cm)title('cameraman原图')
subplot(235)imshow(cm_noise)title('cameraman加噪图')
subplot(236)imshow(cm_filter)title('cameraman去噪')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)