《同态滤波处理光照不均匀图像Matlab代码(共2页).doc》由会员分享,可在线阅读,更多相关《同态滤波处理光照不均匀图像Matlab代码(共2页).doc(2页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上clear all;% 装载图片,将yourimage换成你要处理的图片img= imread(无标.png);%img=img0(:,:,1);% 显示这个图片J=rgb2gray(img);figure,imshow(J);title(灰度图); figure,imhist(J);figure,imshow(img);title(Original Image);% 构造一个高斯滤波器f_high = 1.0;f_low = 0.4;% 得到一个高斯低通滤波器gauss_low_filter = fspecial(gaussian, 7 7, 1.414);mats
2、ize = 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;% 显示高通滤波期的频率响
3、应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(巴特沃斯高通滤波结果);% 由于被处理的图象是经过对数变换的,我们再用幂变换将图
4、象恢复过来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(中值滤波处理); %显示中值滤波后的图像专心-专注-专业