how to detect objects in a box in a greyscale image

5 ビュー (過去 30 日間)
Pravindkumaran Baskaran
Pravindkumaran Baskaran 2022 年 9 月 28 日
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.

採用された回答

Image Analyst
Image Analyst 2022 年 9 月 28 日
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.
  3 件のコメント
Pravindkumaran Baskaran
Pravindkumaran Baskaran 2022 年 9 月 29 日
Thank you very much! managed to solve it

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by