A list,

1 the histogram

Before we move on to color histograms, let’s talk a little bit about histograms. Histogram, as a simple and effective feature descriptor based on statistical properties, is widely used in computer vision. Its advantages are mainly reflected in two aspects: first, for any image region, histogram feature extraction is simple and convenient; Second, histogram represents the statistical characteristics of the image region, can effectively represent the multi-modal feature distribution, and has a certain rotation invariance itself. Therefore, in the field of computer vision, based on the characteristics of different underlying various novel histogram descriptor emerge in endlessly, including luminance histogram, color histogram and HOG, local binary pattern histogram, etc. The color histogram is the most widely used target tracking field descriptor, the traditional color histogram is sensitive to illumination changes, however, Meanwhile, the pixel position distribution in the target region is completely ignored.

2 color histogram

That is, the number of pixels in a pixel value range, where X axis is pixel value and Y is number.



3 Color histogram

Color image has three channels, we can take out its three channels to draw. You can look at the distribution of pixels on each channel to get which color is more abundant in the original picture.



Histogram equalization

The function of histogram equalization is image enhancement.

There are two difficult questions, one is why the cumulative distribution function is selected, and the other is why the pixel values will be evenly distributed after the cumulative distribution function is used.

First question. In the process of equalization, two conditions must be ensured: (1) no matter how the pixel is mapped, it must be guaranteed that the original size relationship remains unchanged. Brighter areas are still brighter, and darker areas are still dark, but the contrast is increased, and the light and shade must not be reversed; ② If it is an eight-bit image, the value range of the pixel mapping function should be between 0 and 255, and cannot exceed the boundary. Combining the above two conditions, the cumulative distribution function is a good choice, because the cumulative distribution function is a monotone increment function (controlling the size relationship), and the range is 0 to 1 (controlling the out-of-bounds problem), so the cumulative distribution function is used in histogram equalization.

Second question. The cumulative distribution function has some good properties, so how to use the cumulative distribution function to make the histogram equalization? Comparing the probability distribution function and the cumulative distribution function, the former two-dimensional image is uneven, the latter is monotonically increasing. Histogram equalization, the mapping method is



Ii. Source code

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

% Last Modified by GUIDE v2. 5 19-Apr- 2016. 17:05:45

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @gui_OpeningFcn, ...
                   'gui_OutputFcn',  @main_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


% --- Outputs from this function are returned to the command line.
function varargout = main_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; %%GUI interface initializationfunction gui_OpeningFcn(hObject, eventdata, handles, varargin)
axes( handles.axes1 )
imshow( 'GUI. JPG' ) ;
axes( handles.axes2 )
imshow( 'GUI. JPG'); axes( handles.axes3 ) imshow('GUI. JPG'); axes( handles.axes4 ) imshow('GUI. JPG'); handles.output = hObject;set( handles.slider1 , 'Value' , 0.8 );
set( handles.edit1 , 'String' ,0.8); guidata(hObject, handles); %% Opens the test image % -- Executes on button press in open_test_img.function open_test_img_Callback(hObject, eventdata, handles)
% hObject    handle to open_test_img (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)Global file % defines the global variable [filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.gif';'*.png';'*.tif';'*.tga'},'Select test image'); % Displays the dialog box file=strcat(pathname,filename); % Generated image path and image name I=imread(file); Axes (handles. Axes1); % Display the open image imshow(I) in the first coordinate system; %% to train % -- Executes on button press in start_test.function start_test_Callback(hObject, eventdata, handles)
% hObject    handle to start_test (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)Global filename WAV_num mydir WAV_path_list % global variable h= waitbar(0.'Training in progress, please wait... ');
for j=1:wav_num
    str= strcat(fullfile(mydir, wav_path_list(j).name));
    I=imread(str);
    [count1,I] = GetRgbHist(str);
    Count{j}=count1;
    II{j}=I;
    waitbar( j/wav_num ) ;
end
save('Parametre.mat'.'Count'.'II'); close(h); %% Exit button % -- Executes on button press in close.function close_Callback(hObject, eventdata, handles)
% hObject    handle to close (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close;


% --- Executes on button press in open_xunlian.
function open_xunlian_Callback(hObject, eventdata, handles)
% hObject    handle to open_xunlian (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)Global filename WAV_num mydir WAV_path_list % Global variable mydir=uigetdir('c:'.'Please select the directory where the training sample is located'); Wav_path_list = dir(fullfile(mydir,'*.jpg'));
wav_num=length(wav_path_list);
filename={wav_path_list.name};
str = sprintf('This directory contains % D image files',wav_num); msgbox(str); %% begin to detect % -- Executes on button press in start_jiance.function start_jiance_Callback(hObject, eventdata, handles)
% hObject    handle to start_jiance (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
load 'Parametre.mat';
[a,b]=size(II);
global file  
[count2,I2] = GetRgbHist(file);
%bbbbb=count2
for i=1:b
value(i) = imsimilar(Count{i},count2,2);
end
Copy the code

3. Operation results

Fourth, note

Version: 2014 a

Complete code or ghostwrite plus 1564658423