Compare images

download Compare images

If you can't read please download the document

description

This document prefers about compare images with various type .

Transcript of Compare images

function varargout = Compare(varargin)% COMPARE MATLAB code for Compare.fig% COMPARE, by itself, creates a new COMPARE or raises the existing% singleton*.%% H = COMPARE returns the handle to a new COMPARE or the handle to% the existing singleton*.%% COMPARE('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in COMPARE.M with the given input arguments.%% COMPARE('Property','Value',...) creates a new COMPARE or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before Compare_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to Compare_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 Compare% Last Modified by GUIDE v2.5 15-Oct-2013 12:44:50% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Compare_OpeningFcn, ... 'gui_OutputFcn', @Compare_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 Compare is made visible.function Compare_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 Compare (see VARARGIN)% Choose default command line output for Comparehandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes Compare wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = Compare_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 structurevarargout{1} = handles.output;% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% 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)% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% 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)% --- Executes on key press with focus on pushbutton1 and none of its controls.function pushbutton1_KeyPressFcn(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata structure with the following fields (see UICONTROL)% Key: name of the key that was pressed, in lower case% Character: character interpretation of the key(s) that was pressed% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed% 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 pushbutton1.function pushbutton1_ButtonDownFcn(hObject, eventdata, handles)% 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)[FileName,PathName] = uigetfile('*.jpg','Select an image');global I1;I1 =imread(strcat(PathName,FileName));axes(handles.axes1);imshow(I1);% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton6.function pushbutton6_Callback(hObject, eventdata, handles)% hObject handle to pushbutton6 (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 pushbutton5.function pushbutton5_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)[FileName,PathName] = uigetfile('*.jpg','Select an image');global I2;I2 =imread(strcat(PathName,FileName));axes(handles.axes3);imshow(I2);% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton6.function pushbutton6_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to pushbutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global I1;global I2;global I3;global I4;global I5;% convert images to type double (range from from 0 to 1 instead of from 0 to 255)Imaged1 = im2double(I1);Imaged2 = im2double(I2);Imaged3 = im2double(I3);Imaged4 = im2double(I4);Imaged5 = im2double(I5);% reduce three channel [ RGB ] to one channel [ grayscale ]Imageg1 = rgb2gray(Imaged1); Imageg2 = rgb2gray(Imaged2); Imageg3 = rgb2gray(Imaged3); Imageg4 = rgb2gray(Imaged4); Imageg5 = rgb2gray(Imaged5); % Calculate the Normalized Histogram of Image 1 and Image 2hn1 = imhist(Imageg1)./numel(Imageg1); hn2 = imhist(Imageg2)./numel(Imageg2); hn3 = imhist(Imageg3)./numel(Imageg3); hn4 = imhist(Imageg4)./numel(Imageg4); hn5 = imhist(Imageg5)./numel(Imageg5); % Calculate the histogram error/ Differencef1 = sum((hn1 - hn2).^2); f2 = sum((hn1 - hn3).^2); f3 = sum((hn1 - hn4).^2); f4 = sum((hn1 - hn5).^2); set(handles.text2,'String',f1)set(handles.text3,'String',f2)set(handles.text4,'String',f3)set(handles.text5,'String',f4)% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton3.function pushbutton3_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)[FileName,PathName] = uigetfile('*.jpg','Select an image');global I3;I3 =imread(strcat(PathName,FileName));axes(handles.axes4);imshow(I3);% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton4.function pushbutton4_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)[FileName,PathName] = uigetfile('*.jpg','Select an image');global I4;I4 =imread(strcat(PathName,FileName));axes(handles.axes5);imshow(I4);% --- If Enable == 'on', executes on mouse press in 5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton2.function pushbutton2_ButtonDownFcn(hObject, eventdata, handles)% 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)[FileName,PathName] = uigetfile('*.jpg','Select an image');global I5;I5 =imread(strcat(PathName,FileName));axes(handles.axes6);imshow(I5);