同态滤波处理光照不均匀图像Matlab代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

clearall;%装载图片,将yourimage换成你要处理的图片img=imread('无标.png');%img=img0(:,:,1);%显示这个图片J=rgb2gray(img);figure,imshow(J);title('灰度图');figure,imhist(J);figure,imshow(img);title('OriginalImage');%构造一个高斯滤波器f_high=1.0;f_low=0.4;%得到一个高斯低通滤波器gauss_low_filter=fspecial('gaussian',[77],1.414);matsize=size(gauss_low_filter);%由于同态滤波是要滤出高频部分,%所以我们得把这个低通滤波器转换成一个高通滤波器.%f_high和f_low是控制这个高通滤波器形态的参数.gauss_high_filter=zeros(matsize);gauss_high_filter(ceil(matsize(1,1)/2),ceil(matsize(1,2)/2))=1.0;gauss_high_filter=f_high*gauss_high_filter-(f_high-f_low)*gauss_low_filter;%显示高通滤波期的频率响应figure,freqz2(gauss_high_filter);colormap(jet(64));%利用对数变换将入射光和反射光部分分开log_img=log(double(img));%将高斯高通滤波器与对数转换后的图象卷积high_log_part=imfilter(log_img,gauss_high_filter,'symmetric','conv');%显示卷积后的图象figure,imshow(uint8(255*((high_log_part-1.5)/(2.4-1.5))),[]);title('巴特沃斯高通滤波结果');%由于被处理的图象是经过对数变换的,我们再用幂变换将图象恢复过来high_part=exp(high_log_part);minv=min(min(high_part));maxv=max(max(high_part));rimg(:,:,1)=(high_part(:,:,1)-minv(1,1,1))/(maxv(1,1,1)-minv(1,1,1));rimg(:,:,2)=(high_part(:,:,2)-minv(1,1,2))/(maxv(1,1,2)-minv(1,1,2));rimg(:,:,3)=(high_part(:,:,3)-minv(1,1,3))/(maxv(1,1,3)-minv(1,1,3));%得到的结果图象figure,imshow(uint8(255*rimg));title('同态滤波结果');h=rgb2gray(uint8(255*rimg));figure,imhist(h);H=medfilt2(J);%中值滤波figure,imshow(H);title('中值滤波处理');%显示中值滤波后的图像

1 / 2
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功