From: saneman on
I have a few hundred samples/images of characters that I would like to
binarize. If I do:

t = 100;
img = img > t

For most of the images the results are ok. But some of the images gets
either totally black or white. Is there some good way to decide t for
each image?
From: Jos on
saneman <ddd(a)sdf.com> wrote in message
<481f1f56$0$90263$14726298(a)news.sunsite.dk>...
> I have a few hundred samples/images of characters that I
would like to
> binarize. If I do:
>
> t = 100;
> img = img > t
>
> For most of the images the results are ok. But some of the
images gets
> either totally black or white. Is there some good way to
decide t for
> each image?


It all depends on your image(s) and desired output(s)!
Perhaps you can take an adjustable threshold instead of a
fixed one. This could, for instance, be the mean of an
image using "mean(img(:))", median, just above minimum,
mode, etc.

hth
Jos
From: ImageAnalyst on
On May 5, 10:53 am, saneman <d...(a)sdf.com> wrote:
> I have a few hundred samples/images of characters that I would like to
> binarize. If I do:
>
> t = 100;
> img = img > t
>
> For most of the images the results are ok. But some of the images gets
> either  totally black or white. Is there some good way to decide t for
> each image?

-----------------------------------------
saneman:
Well this is where the art of image analysis comes in. Yeah it would
be great if you could just use a fixed threshold to separate your
foreground from your background but often this is not the case. You
want to get to that eventually, but to get there you have to do some
tricky and clever things. Perhaps a global background correction
would solve the problem. Perhaps using morphology. Perhaps it's
locally adaptive histogram equalization. Perhaps use Otsu's method or
some home-grown ad hoc method for splitting the histogram
automatically. Perhaps it's level sets or fast marching. It could be
lots of things. That's where you have to use your ingenuity,
experience, and resources (like the experience of others, articles,
the internet, books, MATLAB demos, etc.) to find a solution. Best
would be if you posted images somewhere and asked here again or in
sci.image.processing. Otherwise we're totally just guessing.
Good luck,
ImageAnalyst