im trying to compare array of images with the no of blobs in an image what is wrong this code how i can fix error " corr2>ParseInputs at 36 iptcheckinput(A, {'logical' 'numeric'}, {'real'}, mfilename, 'A', 1); Error in ==> corr2 at 22 [arr{i},b);
1 次查看(过去 30 天)
显示 更早的评论
figure(1);
I = imread('coins.png');
bw = im2bw(I, graythresh(I));
bw2 = imfill(bw,'holes');
imshow(bw2);
% figure(2);
L = bwlabel(bw2);
blobMeasurements = regionprops(L, bw2, 'all');
nofcoins= size(blobMeasurements, 1);
%figure(3);
imshow(I);
arr={'f1.png','f2.png','f3.png'};
for k= 1 : nofcoins
s = regionprops(L, 'BoundingBox');
rectangle('Position', s(k).BoundingBox);
subimage = I(round(s(k).BoundingBox(2):s(k).BoundingBox(2)+s(k).BoundingBox(4)),round(s(k).BoundingBox(1):s(k).BoundingBox(1)+s(k).BoundingBox(3)));
figure,imshow(subimage);
%%save sub images into subimages folder
% baseFileName =sprintf('Frame %4.4d.png', k);
% folder = 'C:\Users\Moniba Ghafoor\Documents\subimages';
% fullFileName = fullfile(folder, baseFileName);
% imwrite(subimage,fullFileName);
%%comparison with array
for i=1 : 3
[row col]=size(arr{i});
b=imresize(subimage,[row,col]);
c=corr2(arr{i},b);
if c==1
h=msgbox('image match with one of subimage');
end
end
end
0 个评论
回答(1 个)
Walter Roberson
2013-6-14
corr2() is checking to enforce that the first input argument is a logical array or else a numeric array. But what you are passing is arr{i} where arr is a cell array of strings, so arr{i} is a string rather than an array of data. corr2() does not support passing in the name of a file storing images whose image contents are to have correlation run on them.
2 个评论
Image Analyst
2013-6-14
Try
referenceImage = imread(arr{i});
c=corr2(referenceImage, b);
Also change this:
h=msgbox('image match with one of the subimages');
to this:
uiwait(msgbox('image match with one of subimage'));
Otherwise msgbox won't wait for you to respond before it goes on ahead executing more code.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!