1、内容简介
略
 531-可以交流、咨询、答疑
2、内容说明
略
3、仿真分析
%% 数据读取
 clear;clc;close all;
 Imageori=imread('1.jpg');  %打开图像
 Image=im2double(Imageori);%将图像归一化并转换为double数据
 %% 同态滤波
 logI=log(Image+1);  %对数运算,防止图像值为0
 sigma=1414;  filtersize=[7 7];%高斯滤波器参数
 lowfilter=fspecial('gaussian',filtersize,sigma); %构造高斯低通滤波器
 highfilter=zeros(filtersize);%存储高斯高通滤波器模板
 highpara=1; lowpara=0.8;%控制滤波器幅度范围的系数  
 highfilter(ceil(filtersize(1,1)/2),ceil(filtersize(1,2)/2))=1;%4 4为1 向上取证
 highfilter=highpara*highfilter-(highpara-lowpara)*lowfilter; %高斯低通滤波器转换为高斯高通滤波器
 highpart=imfilter(logI,highfilter,'replicate','conv'); %时域卷积实现滤波
 NewImage=highpart; %存储到NewImage当中
 top=max(NewImage(:)); bottom=min(NewImage(:));%取图像的最大值和最小值
 New=(NewImage-bottom)/(top-bottom);New=1.5.*(New);%数据的映射处理,符合人眼视觉特性 线性灰度级变换
 figure(1);
 subplot 121;imshow(Imageori);title('原图');
 subplot 122;imshow(New);title('基于同态滤波的增强图像');
 %% HSV空间改进的多尺度 Retinex 算法
 tic
 hsv=rgb2hsv(New);%将rgb色彩空间转换到hsv色彩空间
 imgh=hsv(:,:,1);imgs=hsv(:,:,2);imgv=hsv(:,:,3);%分别取hsv通道
 [height,width]=size(imgv);%读取图像高宽
 vhigh=zeros(height,width);vlow=zeros(height,width); %存储图像
 w=5;% 定义双边滤波窗口宽度  
 sigma_s=[15 70 110]; sigma_r=[0.05 0.10 0.15]; % 双边滤波的两个标准差参数  
 [X,Y] = meshgrid(-w:w,-w:w); %创建方行网格
 for g=1:3
     Gs = exp(-(X.^2+Y.^2)/(2*sigma_s(g)^2));%计算邻域内的空间权值
     for i=1:1:height    
         for j=1:1:width  
             temp=imgv(max(i-w,1):min(i+w,height),max(j-w,1):min(j+w,width));
             Gr = exp(-(temp-imgv(i,j)).^2/(2*sigma_r(g)^2));%计算灰度邻近权值        
             % W为空间权值Gs和灰度权值Gr的成绩       
             W = 1;            
         end
     end      
     %对入射分量进行伽马变换
 end
 result=cat(3,imgh,imgs,vhigh);%将处理后的通道重新进行拼接
 result=hsv2rgb(result);%将hsv色彩空间重新转换回rgb色彩空间
 figure(2);
 subplot 121;imshow(Imageori);title('原图');
 subplot 122;imshow(result);title('基于双边滤波的MSR');
 toc

4、参考论文
略
  








