how to execute for loop differently?...
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
KSSV
2017 年 4 月 7 日
Jesus...1st image, 2nd image, cropping user.....question is very confusing..needs lots of focus to understand. I quit.
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!