A list,
The Retinex theory started from a series of contributions made by Land and McCann in the 1960s. The basic idea is that the color and brightness of a certain point are not only determined by the absolute light entering the human eye from the point, but also related to the color and brightness around it. The word Retinex is a portmanteau of Retina and Cortex. Land devised the term to indicate that he did not know whether the properties of the visual system depended on either or were related to both. Land’s Retinex model is based on the following:
(1) The real world is colorless, and the color we perceive is the result of the interaction between light and matter. We see water is colorless, but water film – soap film is colorful, that is the film surface light interference results;
(2) Each color region is composed of red, green and blue primary colors of a given wavelength;
(3) The three primary colors determine the color of each unit area. The basic content of Retinex theory is that the color of an object is determined by its ability to reflect long wave (red), medium wave (green) and short wave (blue) light, rather than by the absolute value of reflected light intensity. Retinex theory is based on the consistency of color sensation (color constancy). As shown in the figure below, the image S of the object seen by the observer is obtained by the reflection of the surface of the object to the incident light L, and the reflectivity R is determined by the object itself and is not changed by the incident light L.
The basic assumption of Retinex theory is that the original image S is the product of illumination image L and reflectivity image R, which can be expressed in the following form:
The purpose of retinex-based image enhancement is to estimate the illumination L from the original image S, and thereby decompose the R, eliminating the influence of illumination asymmetry, in order to improve the visual effect of the image, just as the human visual system does. In processing, the image is usually transferred to the logarithmic domain, i.e
Thus, the product relation is transformed into the relation of and:
The core of Retinex method is to estimate illumination L, estimate L component from image S and remove L component to obtain original reflection component R, namely:
The function f(x) performs the estimation of the illuminance L.
2 Understanding of Retinex theory
If you read the paper, then in the next part of the paper, there will be two classic Retinex algorithms: path based Retinex and center/surround based Retinex. Before introducing two classic Retinex algorithms, LET me give a little personal understanding so that those who are new to the theory can understand it more quickly. Of course, if THERE is a problem with my understanding, please help to point out.
As far as I can understand, Retinex theory is similar to noise reduction. The key of the theory is the reasonable assumption of image composition. If the image seen by the observer is regarded as an image with multiplicative noise, then the component of the incident light is a multiplicative, relatively uniform noise with slow transformation. What Retinex algorithm does is to reasonably estimate the noise in each position of the image and remove it.
In extreme cases, we can assume that the components in the whole image are uniform, so the simplest way to estimate the illumination L is to take the mean value of the whole image after transforming the image to the logarithmic domain. Therefore, I designed the following algorithm to verify my conjecture, and the process is as follows:
(1) Transform the image to the logarithmic domain
(2) Normalization to remove additive components
(3) Compute the exponent of the result obtained in Step 3 and inversely transform to the real number field
2 dark channel
2.1 He Kaiming’s Dark Channel Prior defogging algorithm is a well-known algorithm in the FIELD of CV bound defogging. The paper on this algorithm, “Single Image Haze Removal Using Dark Channel Prior”, won the CVPR Best paper of 2009. The author made statistics of a large number of fog-free images and found a rule: among the RGB three color channels of each image, there was always one channel with a very low gray value, almost approaching 0. Based on this priori knowledge which can almost be regarded as a theorem, the author proposes a dark channel priori defogging algorithm.
The mathematical expression of the dark channel is:
2.1 Principle of dark channel defogging
Ii. Source code
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 anew 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. Select file buttonfunction pushbutton1_Callback(hObject, eventdata, handles)
axes(handles.axes5); Axes [filename, pathName]= uigetFile ({'*.jpg';'*.png'},'Select test image file');
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 orover pushbutton2. function pushbutton4_Callback(hObject, eventdata, handles) p=getimage(handles.axes5); J=darktest(p); Axes (handles. Axes6); % binding result output inaxes6
imshow(J);
function out = Retinex(filename)
I = filename;
R = I(:, :, 1);
[N1, M1] = size(R);
R0 = double(R);
Rlog = log(R0+1);
Rfft2 = fft2(R0);
sigma = 250;
F = fspecial('gaussian', [N1,M1], sigma);
Efft = fft2(double(F));
DR0 = Rfft2.* Efft;
DR = ifft2(DR0);
DRlog = log(DR +1);
Rr = Rlog - DRlog;
EXPRr = exp(Rr);
MIN = min(min(EXPRr));
MAX = max(max(EXPRr));
EXPRr = (EXPRr - MIN)/(MAX - MIN);
EXPRr = adapthisteq(EXPRr);
G = I(:, :, 2);
G0 = double(G);
Glog = log(G0+1);
Gfft2 = fft2(G0);
DG0 = Gfft2.* Efft;
DG = ifft2(DG0);
Copy the code
3. Operation results
Fourth, note
Version: 2014 a