Matlab Code for PCA based Image Fusion

6,000.00

This project explains Image fusion based on PCA Method

100 in stock

SKU: Matlab Code for PCA based Image Fusion Category:

Description

PCA based Image Fusion

PCA transformation is a statistical method. It transforms a group of related variables into a group of the original variables. The aim is to compress multi-band image information into an image and information can perform maximum in the new image. During the fusion process, it first carries on PCA transformation so that the gray scale mean and variance are consistent with PCA component of the image.

Demonstration Video

matlab code for pca based image fusion

Block diagram of PCA Based Image fusion

pca based image fusion

PCA is the simplest true eigenvector-based multivariate analysis. It involves ways for identifying and to show patterns in data, in such a way as to highlight their similarities and differences, and thus reduce dimension without loss of data. In this method first the column vectors are extracted, from respective input image matrices. The covariance matrix is calculated. Diagonal elements of covariance vector will contain variance of each column vector. The Eigen values and the vectors of covariance matrix are calculated.  Normalize column vector corresponding to larger Eigen value by dividing each element with mean of Eigen vector. Those normalized Eigen vector values act as the weight values and are multiplied with each pixel of input image. Sum of the two scaled matrices are calculated and it will be the fused image matrix.
The information flow diagram of PCA-based image fusion algorithm is shown in figure 4. The input images (images to be fused) I1(x, y) and I2(x, y) are arranged in two column vectors and their empirical means are subtracted. The resulting vector has a dimension of n x 2, where n is length of the each image vector. Compute the eigenvector and eigen values for this resulting vector are computed and the eigenvectors corresponding to the larger eigen value obtained[7] .The
fused image is:
If(x,y) = P1I1(x,y) + P2I2(x,y)

Major Steps in PCA Algorithm

Following steps should be followed for using PCA algorithms for fusion of images. Let the source images (images to be fused) be arranged in two-column vectors. The steps followed to project this data into 2-D subspaces are . Organize the data into column vectors. The resulting matrix Z is of dimension 2 x n. Then compute the empirical mean along each column. The empirical mean vector Me has a dimension of 1 x 2. Subtract the empirical mean vector Me from each column of the data matrix Z. The resulting matrix X is of dimension 2 x n. Find the covariance matrix C of X i.e. C=XXT mean of expectation = cov(X). Compute the eigenvectors V and eigen value D of C
and sort them by decreasing Eigen-value. V and D are of dimension 2 x 2. Consider the first column of V which corresponds to larger eigen value to compute P1 and P2

pca

Matlab Code for PCA based Image Fusion

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

% Last Modified by GUIDE v2.5 22-Oct-2006 19:11:30

% Begin initialization code – DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @GUIFINAL_OpeningFcn, …
‘gui_OutputFcn’, @GUIFINAL_OutputFcn, …
‘gui_LayoutFcn’, [] , …
‘gui_Callback’, []);
if nargin & isstr(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 GUIFINAL is made visible.
function GUIFINAL_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 GUIFINAL (see VARARGIN)

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

A=ones(256,256);
axes(handles.one);
imshow(A);
axes(handles.two);

imshow(A);
axes(handles.three);
imshow(A);

% Update handles structure

guidata(hObject, handles);

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

% — Outputs from this function are returned to the command line.
function varargout = GUIFINAL_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 image1.
function image1_Callback(hObject, eventdata, handles)
% hObject handle to image1 (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’, ‘Pick an Image’);

if isequal(filename,0) | isequal(pathname,0)

warndlg(‘User pressed cancel’)
else

[M1,ma] = imread([pathname, filename]);
% if isind(M1) & ~isempty(ma)
% M1 = 256*double(ind2gray(M1,ma));
% else
% if isgray(M1)
% M1 = double(M1);
% else
% M1 = double(rgb2gray(M1));
% end;
% end;
% Speichern in Userdata
handles.M1 = M1;

axes(handles.one);
imshow(M1);

handles.filename1=filename;
% Update handles structure
guidata(hObject, handles);

end

% — Executes on button press in image2.
function image2_Callback(hObject, eventdata, handles)
% hObject handle to image2 (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’, ‘Pick an Image’);

if isequal(filename,0) | isequal(pathname,0)

warndlg(‘User pressed cancel’)
else

%

[M2,ma] = imread([pathname, filename]);
% if isind(M2) & ~isempty(ma)
% M2 = 256*double(ind2gray(M2,ma));
% else
% if isgray(M2)
% M2 = double(M2);
% else
% M2 = double(rgb2gray(M2));
% end;
% end;
% Speichern in Userdata
handles.M2 = M2;
% handles.pathname = pathname;
axes(handles.two);
% Bild anzeigen
imshow(M2);

handles.filename2=filename;
% Update handles structure
guidata(hObject, handles);

end

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

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

% — Executes on selection change in p1.
function p1_Callback(hObject, eventdata, handles)
% hObject handle to p1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,’String’) returns p1 contents as cell array
% contents{get(hObject,’Value’)} returns selected item from p1

% — Executes on button press in fusenow.
function fusenow_Callback(hObject, eventdata, handles)
% hObject handle to fusenow (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

filename2 = handles.M1;
filename1 = handles.M2;
contents = get(handles.p1,’Value’);

switch contents

case 1
M1=filename1;
M2=filename2;
M1=double(M1);
M2=double(M2);
F = selb(M1,M2,3);
axes(handles.three);
imshow(F,[]);

case 2
M1=filename1;
M2=filename2;
M1=double(M1);
M2=double(M2);
F = selc(M1,M2,4);
axes(handles.three);
imshow(F,[]);
case 3
M1=filename1;
M2=filename2;
M1=double(M1);
M2=double(M2);
F = -selc(-M1,-M2,4);
axes(handles.three);
imshow(F,[]);
case 4
M1=filename1;
M2=filename2;
M1=double(M1);
M2=double(M2);
Y = fuse_pca(M1, M2)
axes(handles.three);
imshow(Y,[]);
end

Reviews

There are no reviews yet.

Be the first to review “Matlab Code for PCA based Image Fusion”

Your email address will not be published. Required fields are marked *

ten + 4 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.