Error using == Matrix dimensions must agree.
Ältere Kommentare anzeigen
I'm using the code below to find values, that is smaller than 500, but I get this error:
"Error using == Matrix dimensions must agree".
any one knows how to fix this problem?
thanks.
my code:
// BW is an image that I'm working on.
L = bwlabeln(BW);
s = regionprops(L);
Areal=[s.Area];
[~,dx] = find(Areal >= 500);
BW(L == dx)=0;
figure (5)
imagesc(BW)
1 Kommentar
Adam
am 14 Okt. 2014
Does the error message not indicate the line which caused it?
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 14 Okt. 2014
You could try this:
% Prior to here, use your same code to get BW. Then...
labeledImage = bwlabeln(BW);
s = regionprops(labeledImage,'Area');
allAreas = [s.Area];
% Do the size filtering.
keeperIndexes = find(allAreas <= 500); % These are the ones that we want!
filteredLabeledImage = ismember(labeledImage, keeperIndexes);
% Apply a variety of pseudo-colors to the remaining regions and display them
coloredLabelsImage = label2rgb (filteredLabeledImage , 'hsv', 'k', 'shuffle');
% Display the pseudo-colored image.
imshow(coloredLabelsImage);
% Now measure again on the new labeled image to get areas
% of only those blobs > 50 and <= 500 pixels in area.
s = regionprops(filteredLabeledImage,'Area');
allAreas = [s.Area];
Kategorien
Mehr zu Region and Image Properties finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!