Page 1 of 1

Make the foreground white (light) & background black (dark)

PostPosted: Mon Sep 16, 2019 7:45 pm
by JerryNixon
As I understand it, a black/dark background and a white/light foreground helps deliver the best Blob detection results.

I suppose I should confirm this is correct before I proceed to the next part of my question. Is that correct?

Q: Is there a reliable approach or filter I could use to ensure my image are correctly formatted for best results for Blob detection?

I have included four files that show the kind of variety we see.

Thank you.

Re: Make the foreground white (light) & background black (da

PostPosted: Tue Sep 17, 2019 11:22 am
by andrew.kirillov
Yes, Blob Counter expects background to be black and objects to be white (non black). So usually you do either grayscaling and the tresholding or some color filtering.

There is no automatic routine, which will process image to make it suitable for Blob Counter. Hard to make a generic one, which fits all possible tasks.

However, in your case you may try crafting something. If you grayscale your 3 images and check their histograms, then you will find that background gets the highest peak. Find the middle point between those 2 peaks and use for thresholding. If the highest peak was on the left, then all good – background will be black. If the highest peak was on the right, you will need to invert the image to get background from white to black.

histogram.png
histogram.png (2.35 KiB) Viewed 192 times