how to execute for loop differently?...

1 Ansicht (letzte 30 Tage)
Maruthi Maruthi
Maruthi Maruthi am 7 Apr. 2017
Kommentiert: KSSV am 7 Apr. 2017
In my code, I'm extracting and comparing images from the folder and the user is cropped at the figure. whether user cropped images and folder existing image features are same or not . when the user cropped and the existing folder images comparison is fine for the first time and when compared for the 2nd user cropped to already existing image folder is now comparing the first folder image comparison again. I don't need that. when comparison comes, user cropped first image and existing folder first image compare and again compare with the user cropped 2nd image and existing folder 2nd comparison I need. In my code, user cropped first image comparison with already existing folder 1st image and comparing the user cropped 2nd image and comparing existing folder 1st and 2nd image so on... Please help me for my project.
function percent_match(uname1,imgs)
disp(uname1);
myDir = 'user_images/';
myDir=strcat(myDir,uname1)
myDir=strcat(myDir,'/');
jpgFiles = dir([myDir '*.jpg']);
numFiles = length(jpgFiles);
mydata = cell(1,numFiles);
% mydata = zeros(numFiles);
for k = 1:numFiles
mydata{k} = imread([myDir jpgFiles(k).name]);
mydata{k}=rgb2gray(mydata{k});
imgs=rgb2gray(imgs);
mydataPoints=detectSURFFeatures(mydata{k});
strong1 = mydataPoints.selectStrongest(50);
imgsPoints=detectSURFFeatures(imgs);
strong2 = imgsPoints.selectStrongest(50);
[mydataFeatures,mydataPoints1]=extractFeatures(mydata{k},strong1);
[imgsFeatures,imgsPoints]=extractFeatures(imgs,strong2);
mydataPairs=matchFeatures(mydataFeatures,imgsFeatures);
matchedmydataPoints = mydataPoints(mydataPairs(:, 1), :);
matchedimgsPoints = imgsPoints(mydataPairs(:, 2), :);
[tform, inlierBoxPoints, inlierScenePoints] = ...
estimateGeometricTransform(matchedmydataPoints, matchedimgsPoints, 'affine');
boxPolygon = [1, 1;... % top-left
size(mydata{k}, 2), 1;... % top-right
size(mydata{k}, 2), size(mydata{k}, 1);... % bottom-right
1, size(mydata{k}, 1);... % bottom-left
1, 1];
newBoxPolygon = transformPointsForward(tform, boxPolygon);
%figure;
%imshow(imgs);
%hold on;
%line(newBoxPolygon(:, 1), newBoxPolygon(:, 2), 'Color', 'y');
%title('Detected Box');
numPairs = length(mydataPairs); %the number of pairs
percentage = (numPairs*2);
if percentage >75
disp('we have this');
disp(percentage);
else
disp('we dont have this')
end
break;
end
end
  1 Kommentar
KSSV
KSSV am 7 Apr. 2017
Jesus...1st image, 2nd image, cropping user.....question is very confusing..needs lots of focus to understand. I quit.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by