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

Ii. Source code

function varargout = MainForm(varargin)
% MAINFORM MATLAB code for MainForm.fig
%      MAINFORM, by itself, creates a new MAINFORM or raises the existing
%      singleton*.
%
%      H = MAINFORM returns the handle to a new MAINFORM or the handle to
%      the existing singleton*.
%
%      MAINFORM('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MAINFORM.M with the given input arguments.
%
%      MAINFORM('Property'.'Value',...). creates anew MAINFORM or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before MainForm_OpeningFcn gets called.  An
%      unrecognized property name orinvalid value makes property application % stop. All inputs are passed to MainForm_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 MainForm

% Last Modified by GUIDE v2. 5 5-Apr- 2021. 17:16:36

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @MainForm_OpeningFcn, ...
    'gui_OutputFcn',  @MainForm_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 MainForm is made visible.
function MainForm_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 MainForm (see VARARGIN)

% Choose default command line output for MainForm
handles.output = hObject;
handles.Img1 = 0; % handles.Img2 =0;
% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = MainForm_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; % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --function File_Callback(hObject, eventdata, handles)
% hObject    handle to File (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function FileOpen_Callback(hObject, eventdata, handles)
% hObject    handle to FileOpen (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% Turn on Warning off all; % loading images [FileName, the PathName, FilterIndex] = uigetfile ({'*.jpg; *.tif; *.png; *.gif'.'All image files'; .'*. *'.'All files' },'Load image'.'.\images\\sweden_input.jpg');
if isequal(FileName, 0) || isequal(PathName, 0)
    return;
end
InitFig(hObject, handles);
Img1 = imread(fullfile(PathName, FileName));
axes(handles.axes1);
imshow(Img1, []);
handles.Img1 = Img1;
handles.Img2 = 0; guidata(hObject, handles); % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --function Exist_Callback(hObject, eventdata, handles)
% hObject    handle to Exist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close(a); % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --function About_Callback(hObject, eventdata, handles)
% hObject    handle to About (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
msgbox('Low contrast Image Enhancement System, Global and Local Histogram Equalization and Image Contrast Enhancement Algorithm Based on RETINEX Theory'.'Prompt message');

function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0.'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor'.'white');
end


% --------------------------------------------------------------------
function ImageDeFog_Callback(hObject, eventdata, handles)
% hObject    handle to ImageDeFog (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function ColorSpaceDeFog_Callback(hObject, eventdata, handles)
% hObject    handle to ColorSpaceDeFog (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function RetinexDeFog_Callback(hObject, eventdata, handles)
% hObject    handle to RetinexDeFog (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if isequal(handles.Img1, 0)
    msgbox('Please load the image! '.'Prompt message');
    return;
end
Img2 = RemoveFogByRetinex(handles.Img1, 0);
axes(handles.axes2); imshow(Img2, []);
handles.Img2 = Img2;
guidata(hObject, handles);
set(handles.textInfo, 'String'.'Image contrast enhancement algorithm based on RETINEX theory. '); % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --function help_Callback(hObject, eventdata, handles)
% hObject    handle to help (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Flow_Callback(hObject, eventdata, handles)
% hObject    handle to Flow (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
str = 'Low contrast image enhancement system, first load the image and display, then select contrast enhancement algorithm, and finally observe the histogram contrast effect. ';
msgbox(str, 'Prompt message'); % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --function SaveGUI_Callback(hObject, eventdata, handles)
% hObject    handle to SaveGUI (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% screenshotsSnapImage(a); % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --function SaveResult_Callback(hObject, eventdata, handles)
% hObject    handle to SaveResult (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)% to saveif isequal(handles.Img2, 0)
    msgbox('Contrast enhancement please! '.'Prompt message');
    return;
end
Copy the code

3. Operation results







Fourth, note

Version: 2014 a