very low score similarity in pca
1 view (last 30 days)
Show older comments
hi everybody...i used pca to get similarity between images ..the problem is the score is very
low when enter the images to compering with the images in files
this is code
mean_face = mean(images, 2); shifted_images = images - repmat(mean_face, 1, num_images);
% steps 3 and 4: calculate the ordered eigenvectors and eigenvalues [evectors, score, evalues] = princomp(images');
% step 5: only retain the top 'num_eigenfaces' eigenvectors (i.e. the principal components) num_eigenfaces = 2; evectors = evectors(:, 1:num_eigenfaces);
% step 6: project the images into the subspace to generate the feature vectors features = evectors' * shifted_images;
%%%%%%%%%%%%%%%%praper input imag%%% img3 = rgb2gray(imread('777.jpg'));
background = imopen(img3,strel('disk',15)); img3 = imabsdiff(img3,background);%strel,Create morphological structuring element (STREL)
myfilter = fspecial('gaussian',[5 5], 0.5);
myfilteredimage = imfilter(img3, myfilter, 'replicate');
%nois=imnoise(myfilteredimage,'salt & pepper');
medf= medfilt2(myfilteredimage,[8 8]);
%%%%%%%%%%%%%%%%%
se = strel('disk',4); img4 = edge(medf,'canny',0.08); img4= bwareaopen(img4,30);
input_image = imclose(img4,se); %closeBW=imfill(closeBW,'holes'); input_image=imresize(input_image,[80, 70]);
%%%%%%%%%%%%%%%%%%classifcation
% calculate the similarityty of the input to each training image feature_vec = evectors' * (input_image(:) - mean_face); similarity_score = arrayfun(@(n) 1 / (1 + norm(features(:,n) - feature_vec)), 1:num_images);
% find the image with the highest similarity [match_score, match_ix] = max(similarity_score);
% display the result figure, imshow([input_image reshape(images(:,match_ix), image_dims)]); title(sprintf('matches %s, score %f', filenames(match_ix).name, match_score));
my quetions : why the score is very very low..(score =.0032)??? >how to specify the num_eigenfaces..(principal components, which is set by the variable num_eigenfaces)??? >>when decrease the num_eignface the score increase (why)??
plz help me
2 Comments
Image Analyst
on 2 Jun 2014
Haven't I ever asked you to read this before? If not, here it is again http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!