【图像去雾】基于Retinex算法实现图像去雾matlab代码

1 简介

本文提出了一种基于Retinex的雾霾图像的去雾增强算法,将受到雾霾天气影响的欠清晰图像用Retinex算法进行处理,获得增强图像.针对图像处理后出现噪点的问题,使用中值滤波对图像进行滤波处理,去除噪声.仿真实验表明该算法对受到雾霾天气影响的图像有较好的增强效果,降低噪声,画面清晰.

Retinex 是由 Edwin.H.Land 提出的阐述人类的视觉系统如何对捕获到的视觉信息进行处理并在大脑皮层中形成影像的模型。Retinex 理论解释了为何在外界光照强度不同的条件下,视觉颜色还是恒定的。Retinex 理论认为人类的大脑皮层所形成的关于目标物体的颜色信息只与目标物体表面的反射性质有关,与外界光照强度无关。人类的视觉系统能够将所获取的视觉信息分为外界光照变化信息和物体表面的本质信息,前者变化表现为平滑的照明梯度曲线,后者变化表现为突变的照明梯度曲线。通过计算外界光照强度的变化信息就可以获得物体表面的本质信息,从而获得物体的本来面貌特征,形成颜色恒常性。Land 通过实验证明了人类对于颜色的感知在一定程度上与外界光的光谱无关。Land[38]认为人类具有视网膜皮质系统,能够对三种锥体细胞所获得的视觉信息进行处理,它能够消除外界光照的影响,只保留目标物体表面的特征信息。视网膜皮质系统通过比较获得的图像中各个点的相对反射值并综合三种锥体细胞的结果,从而产生颜色恒常性。Retinex 理论很好的诠释了颜色恒常性,并被大量科学研究所证实。后来,很多研究者在这一理论的基础上提出了多种算法,例如单尺度Retinex算法、多尺度Retinex算法、McCann’s Retinex 算法等等[39-40]。尽管这些算法不尽相同,但其基本原理都非常相似,都是通过对原始图像进行高斯滤波来获取照度图像,并尽量准确的获取照度图像,最后将照度图像从原始图像中分离出来,从而获得反射图像。

2 部分代码

function varargout = selectFile(varargin)
% SELECTFILE MATLAB code for selectFile.fig
%     SELECTFILE, by itself, creates a new SELECTFILE or raises the existing
%     singleton*.
%
%     H = SELECTFILE returns the handle to a new SELECTFILE or the handle to
%     the existing singleton*.
%
%     SELECTFILE('CALLBACK',hObject,eventData,handles,...) calls the local
%     function named CALLBACK in SELECTFILE.M with the given input arguments.
%
%     SELECTFILE('Property','Value',...) creates a new SELECTFILE or raises the
%     existing singleton*. Starting from the left, property value pairs are
%     applied to the GUI before selectFile_OpeningFcn gets called. An
%     unrecognized property name or invalid value makes property application
%     stop. All inputs are passed to selectFile_OpeningFcn via varargin.
%
%     *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
%     instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help selectFile

% Last Modified by GUIDE v2.5 07-Mar-2019 09:47:39

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                  'gui_Singleton',  gui_Singleton, ...
                  'gui_OpeningFcn', @selectFile_OpeningFcn, ...
                  'gui_OutputFcn',  @selectFile_OutputFcn, ...
                  'gui_LayoutFcn', [] , ...
                  'gui_Callback',   []);
if nargin && ischar(varargin{1})
   gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
  [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
   gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before selectFile is made visible.
function selectFile_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject   handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
% varargin   command line arguments to selectFile (see VARARGIN)

% Choose default command line output for selectFile
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes selectFile wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = selectFile_OutputFcn(hObject, eventdata, handles) 
% varargout cell array for returning output args (see VARARGOUT);
% hObject   handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in pushbutton1.选择文件按钮
function pushbutton1_Callback(hObject, eventdata, handles)
 axes(handles.axes5);%绑定控制的是那个axes
[filename,pathname]=uigetfile({'*.jpg';'*.png'},'选择测试图片文件');
picturepath=[pathname,filename];
before=imread(picturepath);
imshow(before);  
% hObject   handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)





% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton2.
function pushbutton4_Callback(hObject, eventdata, handles)
p=getimage(handles.axes5);%获取到axes5上显示的图片
J=darktest(p);%进行暗通道先验
axes(handles.axes6);%绑定结果输出在axes6
imshow(J);

%进行RETINEX去雾
k=Retinex(p);
axes(handles.axes7);%绑定结果输出在axes7
imshow(k);
% hObject   handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)

3 仿真结果

4 参考文献

[1]赵苏齐, & 吴健珍. (2016). 基于retinex的雾霾图像去雾算法. 科教导刊(2), 2.

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Matlab科研辅导帮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值