how to detect objects in a box in a greyscale image
7 views (last 30 days)
Show older comments
Pravindkumaran Baskaran
on 28 Sep 2022
Commented: Pravindkumaran Baskaran
on 29 Sep 2022
how can i detect objects in a box in a greyscale image.Managed to make the objects standout but how can i detect the number of objects. Attached two images, original image and the binarised image.
0 Comments
Accepted Answer
Image Analyst
on 28 Sep 2022
I'd use imabsdiff to find the difference between an image with no objects there and your image with objects there. Then threshold that difference image, call imfill, and then count blobs with bwlabel. Here's a start
diffImage = imabsdiff(grayImage, backgroundImage);
mask = diffImage > 10; % Or whatever.
mask = imfill(mask, 'holes');
% Get rid of specks less than 50 pixels in area
mask = bwareaopen(mask, 50);
[labeledImage, numObjects] = bwlabel(mask);
If you need more help, attach your reference background image - the one with no objects present.
More Answers (0)
See Also
Categories
Find more on Explore and Edit Images with Image Viewer App in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!