object recognition using morphological filters

9 views (last 30 days)
Somehow I have to detect the rectangular components at the bottom right of the image:
The result should look something like this:
I though opening by reconstructing is a good start then I have no clue what to do.
Any help is appreciated
  2 Comments
KALYAN ACHARJYA
KALYAN ACHARJYA on 3 Jan 2021
More specific please, if you want help, then you need to make it easy to be helped.
Remi MOrre
Remi MOrre on 3 Jan 2021
I have to detect the objects just like shown in image b

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 3 Jan 2021
Why not just subtract with imabsdiff()?
diffImage = imabsdiff(image1, image2);
bigDifferences = diffImage > 5; % Or whatever.
% Get rid of blobs less than 3 pixels in area
bigDifferences = bwareaopen(bigDifferences, 3); % This is a morphological operation
imshow(bigDifferences, []);
  8 Comments
Remi MOrre
Remi MOrre on 5 Jan 2021
Edited: Remi MOrre on 5 Jan 2021
Ok thanks man you were very helpful. by the way I was able to detect the objects by applyaing erosion followed by thresholding fowllowed by opening the image.
Image Analyst
Image Analyst on 5 Jan 2021
Yes, like I said, if your definition of an object is something bright, you can find it by thresholding. You can find a full demo in my Image Segmentation Tutorial in my File Exchange.
An erosion does a local minimum operation, so that will make things darker and shrink the bright blobs, possibly making the smaller blobs disappear so that only larger bright blobs remain. Then you thresholded which gave you a binary image of those larger bright blobs. An opening is an erosion followed by a dilation so that makes the binary blobs smaller and then enlarges them again to their original size, roughly. What it does is to smooth out the black parts of the image by getting rid of the small blobs and snipping off any "tendrils" or "peninsulas" that may poke out of the bright blobs. It may potentially separate blobs into more blobs so you may want to call bwareaopen() or bwareafilt() after that. I'm not sure the erosion at the very beginning is really necessary, but whatever -- as long as it works and you're happy with the result.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!