remove pixel and height that doesnt meet certain criteria
Afficher commentaires plus anciens
hi sir, in my color detection, I used ismember to set object between pixel 100 and 500. Its worked. however, can I know from the bounding box of object detection, how to remove bounding of blobs that doesnt meet height and width criteria ,say width and height of 100x100 pixels?
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 6 Nov 2012
minwidth = 100; maxwidth = 100; %as far as I can tell from your question
minheight = 100; maxheight = 100; %as far as I can tell from your question
rinfo = regionprops(YourLabeledImage, 'BoundingBox');
bb = [rinfo.BoundingBox];
bbmatches = bb(4) >= minheight & bb(4) <= maxheight & bb(3) >= minwidth & bb(3) >= maxwidth;
Now bbmatches would be a logical array and you can do things like
rinfo(bbmatches)
to select just the relevant boxes.
7 commentaires
Tulips
le 6 Nov 2012
Image Analyst
le 6 Nov 2012
I thought you had already seen my Image Segmentation tutorial where I went over that - you said you knew how to use ismember(). Well anyway, see my answer above.
Tulips
le 6 Nov 2012
Image Analyst
le 6 Nov 2012
Modifié(e) : Image Analyst
le 6 Nov 2012
Use the plot function, as shown in my BlobsDemo mentioned above. Run the demo and you'll see bounding boxes calculated. Then you just use rectangle(), or, what I prefer, plot() to plot the box. Display the image or switch to that axes, then do
hold on;
y = [row1 row1 row2 row2 row1];
x = [col1 col2 col2 col1 col1];
plot(x, y, 'r-');
where the row and column variables are your bounding box edges. Or something like
for k = 1 : numberOfBlobs % Loop through all blobs.
% Find the bounding box of this blob.
thisBlobsBoundingBox = blobMeasurements(k).BoundingBox;
% Plot it in the overlay.
rectangle('Position', thisBlobsBoundingBox);
end
Tulips
le 6 Nov 2012
Image Analyst
le 6 Nov 2012
No. ismember() returns a labeled image, not bounding box coordinates. You'd need to either pick out selectively the bounding boxes that meet your criteria from your measurements (what regionprops returned the first time), or, probably easier, just relabel and call regionprops again. It's regionprops() that returns bounding box coordinates, not ismember().
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!