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

답변 (1개)

Walter Roberson
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
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 CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by