1, Introduction
PCA algorithm is based on image reconstruction method for image feature recognition. There are training samples, multiple test pictures and document descriptions.
Identification steps:
① Select training samples
② Calculate sample average digital feature, digital feature space
③ Read the number to be identified, segment the connected components, and determine the number of numbers to be identified
④ Classification by discriminant
2, Source code
clear all clc close all % Select training data and test data path (i.e. directory) TrainData and TestData) TrainDatabasePath = uigetdir('D:\Program Files\MATLAB\R2007b\work', 'choice[Training data]route' ); TestDatabasePath = uigetdir('D:\Program Files\MATLAB\R2007b\work', 'choice[test data]route'); prompt = {'Enter test image name(1,2):'}; dlg_title = 'PCA Identification input'; num_lines= 1; def = {'1'}; TestImage = inputdlg(prompt,dlg_title,num_lines,def); TestImage = strcat(TestDatabasePath,'\',char(TestImage),'.jpg'); im = imread(TestImage); T = CreateDatabase(TrainDatabasePath);%Create test database [m, A, EigenPos] = PCA(T); OutputName = Recognition(TestImage, m, A, EigenPos);%Recognition output matching image SelectedImage = strcat(TrainDatabasePath,'\',OutputName); SelectedImage = imread(SelectedImage); imshow(im) title('Test image'); figure,imshow(SelectedImage); title('Equivalent image'); unction OutputName = Recognition(TestImage, m, A, EigenPos) % Recognition operation:Compare the two images, map the image to the feature space, and measure the Euclidean distance between them % parameter:TestImage Enter test image path % m (M*Nx1) Mean value of training database % EigenPos (M*Nx(P-1)) Covariance matrix eigenvector of training data % A (M*NxP) Centered image vector matrix % return: OutputName The names in the training database are recognized % All centered images are multiplied by Eigenfaces To map, the mapping vector of each graph will be the corresponding feature vector ProjectedImages = []; Train_Number = size(EigenPos,2); for i = 1 : Train_Number temp = EigenPos'*A(:,i); %Centered image mapping ProjectedImages = [ProjectedImages temp]; end % Extract from the test image PCA features InputImage = imread(TestImage); temp = InputImage(:,:,1); [irow icol] = size(temp); Difference = double(InImage)-m; % Centered test image ProjectedTestImage = EigenPos'*Difference; % Test image feature vector % Calculate the Euclidean distance between the mapped test image and the projection of all centered training images % Set the minimum distance between the measurement image and the corresponding image in the training database Euc_dist = []; for i = 1 : Train_Number q = ProjectedImages(:,i); temp = ( norm( ProjectedTestImage - q ) )^2; Euc_dist = [Euc_dist temp]; end
3, Operation results
4, Remarks
Complete code or write on behalf of QQ 1564658423
Review of previous periods > > > > >
[signal processing] sleep state detection based on matlab HMM [including Matlab source code 050]
[signal processing] CDR noise and reverberation suppression based on MATLAB [including Matlab source code phase 051]
[signal processing] solve the problem of sparse signal recovery based on MATLAB least square method [including Matlab source code phase 052]
[signal processing] audio watermark embedding and extraction based on MATLAB wavelet transform [including Matlab source code phase 053]
[signal processing] signal separation based on matlab ICA algorithm [including Matlab source code phase 054]
[signal processing] archiving of pulse rate of pulse signal based on matlab GUI interface [including Matlab source code phase 237]
[signal processing] virtual signal generator based on matlab GUI interface (various waveforms) [including Matlab source code phase 271]
Matlab based signal generator
[signal processing] design and implementation of digital electronic organ based on MATLAB [including Matlab source code phase 273]
[radar communication] radar digital signal processing based on MATLAB [including Matlab source code phase 281]
[radar communication] simulation of linear frequency modulation (LFM) pulse compression radar based on MATLAB [including Matlab source code phase 283]
[radar communication] airborne radar imaging based on mtatlab range Doppler (RD), CS and RM algorithms [including Matlab source code phase 284]
[radar communication] modern radar system analysis and design [including Matlab source code 285]
[signal processing] integrated speech signal processing platform based on matlab GUI [including Matlab source code phase 290]
[signal processing] voice signal acquisition based on matlab GUI [including Matlab source code phase 291]
[signal processing] speech amplitude modulation based on matlab GUI [including Matlab source code phase 292]
[signal processing] speech synthesis based on matlab GUI [including Matlab source code phase 293]
[signal processing] speech fundamental frequency recognition based on matlab GUI [including Matlab source code phase 294]
[signal processing] voice signal encryption and decryption based on matlab GUI [including Matlab source code phase 295]
[signal processing] speech enhancement based on MATLAB wavelet transform [including Matlab source code 296]
[signal processing] speech Fourier transform noise reduction and mixing based on matlab GUI [including Matlab source code phase 297]
[signal processing] speech enhancement based on matlab GUI Wiener filter [including Matlab source code 298]
[audio processing] GUI voice signal processing based on MATLAB 2 [including Matlab source code 299]
[radar communication] radar positioning based on matlab GUI [including Matlab source code phase 302]
[radar communication] radar pulse compression based on matlab GUI [including Matlab source code phase 303]
[radar communication] radar positioning simulation based on matlab GUI [including Matlab source code phase 304]
[radar communication] identify radar data based on matlab SVM [including Matlab source code phase 305] ##Title
[edge detection] subpixel edge detection based on matlab interpolation [including Matlab source code phase 306]
[pattern recognition] handwritten numeral recognition based on matlab GUI Bayesian minimum error rate [including Matlab source code phase 308]