From: Kenneth Galea on
Hello everyone.

I have a problem regarding thresholding of an image. I'm using Otsu's thresholding method by the command level = graythresh(I) where a threshold is determined according to the image.
Now my problem is that when I have a white backround with a black ruler for example the object is detected perfectly while the background is recognised as background. However when I remove the ruler such that the image detected should be white (i.e. i.e. thresholding is supposed to detect no objects) , lots of gray areas are detected as part of my image:/
How can I eliminate these gray areas??

Thanks
Kenneth
From: ImageAnalyst on
Kenneth :
That's not true. That method forces a threshold to be chosen. In
cases like these, you don't use an automatic threshold, you use a
fixed threshold. You need to do this in conjunction with intensity
correction. This will solve your problem.
-ImageAnalyst

From: Kenneth Galea on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <cce067d5-87e1-4435-9ec8-f8a114c7c816(a)21g2000yqj.googlegroups.com>...
> Kenneth :
> That's not true. That method forces a threshold to be chosen. In
> cases like these, you don't use an automatic threshold, you use a
> fixed threshold. You need to do this in conjunction with intensity
> correction. This will solve your problem.
> -ImageAnalyst
Hi thanks for your reply.

But how can I use a fixed threshold if my objects have different colours?

Thanks
From: Kenneth Galea on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <cce067d5-87e1-4435-9ec8-f8a114c7c816(a)21g2000yqj.googlegroups.com>...
> Kenneth :
> That's not true. That method forces a threshold to be chosen. In
> cases like these, you don't use an automatic threshold, you use a
> fixed threshold. You need to do this in conjunction with intensity
> correction. This will solve your problem.
> -ImageAnalyst

What I mean is that I will have one object at a time in my image ...but the objects have different colours and not necessarily all black..that's why I was using an automatic threshold!!! Initally I used a fixed threshold for example 0.5 but it was not always suitable for differnt coloured objects :( With automatic threshold it was great till unfortunately I met this problem! Is there a solution to this?
Regards
Kenneth
From: ImageAnalyst on
Well then you might have to do more complicated things than
thresholding, such as color classification. See my simple demo here:
http://www.mathworks.com/matlabcentral/fileexchange/26420-simplecolordetection
Actually this color detection demo is so simple that it just uses
thresholding, but on all three color planes and then combines them.
So it's basically chopping out a rectangular gamut out of the 3D RGB
color space. There are more sophisticated color classification method
that can be done if necessary. But you can do this type of thing to
detect your background color and then everything not background will
be foreground (your objects).

If you are able to choose your background color then you might be able
to get your object mask just by looking at a particular color plane,
or by subtracting or dividing your test image by a reference (blank)
background image that has nothing in it except the background (no
objects present).

There are even more methods but we can't get into all possbilities of
methods. It would be best if you posted some images (such as to
http:://drop.io which is the easiest) that illustrate the thresholding
difficulties you are having.