Is there a way to threshold the background out of the image, to leave only the object?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Teshan Rezel
am 3 Aug. 2021
Kommentiert: Tanjena Azim
am 5 Aug. 2021
Hi folks,
I have images that look like the following, and I'm trying to threshold out the background. For some images, this is a very straightforward endeavour. For others, however, it's not that easy because the background and object have similar greyscale levels.
Ultimately, I want to use regionprops() to measure the object's properties.
May I please ask if there's a way to get around this?
My images look like this:
1 Kommentar
Akzeptierte Antwort
Image Analyst
am 4 Aug. 2021
Bearbeitet: Image Analyst
am 4 Aug. 2021
Try imbinarize(). Then check the mean gray level in the center of the mask image and compare it to the mean gray level at the top of the image. If the mask is dark in the center and bright around the top, then invert the mask. Something like (untested)
mask = imbinarize(grayImage);
[rows, columns] = size(mask);
row = round([rows/2-50 : rows/2+50]);
col = round([columns/2-50 : columns/2+50]);
if mean2(mask(1:10)) > mean2(mask(row, col))
% Mask at top is white and in middle is black. Need to invert it.
mask = ~mask;
end
5 Kommentare
Image Analyst
am 5 Aug. 2021
@Tanjena Azim Like I already said, I don't know what NROI is. Plus I'm not a watermark expert. I've only played around with it a little bit - probably less than you.
And I don't think the original poster, @Teshan Rezel, knows or cares about watermarks. It's totally unrelated to this discussion thread.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!