Clear Filters
Clear Filters

How can I detect the object in this noisy image?

24 views (last 30 days)
L'O.G.
L'O.G. on 10 May 2023
Commented: L'O.G. on 10 May 2023
I'm trying to process images like the attached. In this case, there should be an object near the center of the image around test(7,6). The object is roughly elliptical with a major axis of around 6 or 7 pixels. The bright pixels around test(11,6) are from something else that I want to ignore. What is the best way of going about this?
-I tried both global and local thresholding to binarize the image, without success. I think noise is the issue.
-I also tried using a structuring element as a disk and then a morphological technique to locate the object, but that didn't work.
-I think filtering might be the best option. Is there a good filter for this task? imfilter looks promising, but I don't know how the kernel is chosen.

Answers (2)

Image Analyst
Image Analyst on 10 May 2023
Why can't you just threshold?
mask = grayImage > 35;
Beyond that I'm not sure what you want to do. There are functions to throw out blobs touching the edge of the image, or to extract blobs of a certain size range, or to extract a specified number of the larger blobs.
The main problem seems to be poor resolution, though noise is a problem too.
  3 Comments
Image Analyst
Image Analyst on 10 May 2023
You can try a tophat filter. It basically creates a background image by replacing every pixel by the local minimum value and then subtracting that from the original image. So you get an image where little bright spots are the same brightness above the background. Let's say you had a bright bump of 10 gray levels sitting on a bright hump of 200, and another one sitting on a local background of 50 gray levels. Then after the tophat filter, both bumps would have a peak of 10 gray levels because the local background got subtracted away. Generally you'd need a much much larger image to do any kind of filtering. The best way is to use a fixed threshold. It's the most robust because it will work regardless if there is 100% foreground, or 0% foreground or anywhere in between. Basically you do whatever you need to do to get your image into a state where you can use a fixed threshold, such as applying imtophat, imbothat, or adapthisteq or some other steps to "flatten" the image.
L'O.G.
L'O.G. on 10 May 2023
Thank you so much. So just one more thing to clarify: given the roughly elliptical shape of the central blob, would you recommend a disk structuring element for the tophat filter? I was trying that out similar to the procedure you outlined without much success.

Sign in to comment.


Brandon Armstrong
Brandon Armstrong on 10 May 2023
I'm not sure how many images like this you have or how consistent your intensity values are. For the image you attached, I would create a binary mask with a manual threshold and then filter based on region size to get rid of the smaller object.
Check out MathWorks Image Processing for Engineering and Science on Coursera to learn many techniques for segmenting and analyzing images.
load test
Create a mask and choose a manual threshold to set everythign to zero.
mask = ones(size(test), "logical");
mask(test <= 36) = 0;
filteredMask = bwpropfilt(mask, "Area", [6, inf]);
Use the mask to zero out pixels not under the mask
newImage = test;
newImage(~filteredMask) = 0;
imagesc(newImage)
  2 Comments
L'O.G.
L'O.G. on 10 May 2023
Thank you @Brandon Armstrong, would there be a way of automatically finding that threshold rather than manually? I have many such images. That seems to be the issue I'm facing.
Brandon Armstrong
Brandon Armstrong on 10 May 2023
It's going to be tough given the resolution and how close the objects are. There is not much of a decrease in intensity in the one or two pixels separating the areas you want. The suggestion from @Image Analyst sounds like the best thing to try.
If you have a lot of images, you can create a function that works on one or two test images and then apply it to all the images and see the results using the Image Batch Processor.

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!