Main Page | Report this Page
 
   
Science Forum Index  »  Image Processing Forum  »  Good way to binarize image?...
Page 1 of 1    
Author Message
saneman...
Posted: Mon May 05, 2008 11:08 am
Guest
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?
Bob...
Posted: Mon May 05, 2008 11:08 am
Guest
On May 5, 9:08 am, saneman <d... at (no spam) sdf.com> wrote:
Quote:
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 looks like you are using matlab. In that case, look up the help on
graythresh. Be warned that the output of graythresh, even though it is
called LEVEL is a number from 0 to 1 so study their documentation
carefully.

If you are not using matlab, do a search on otsu's method. This is
pretty standard and many image processing packages have functions to
implement it.
Rupert Swarbrick...
Posted: Mon May 05, 2008 11:49 am
Guest
saneman <ddd at (no spam) sdf.com> writes:

Quote:
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?

The next simplest strategy is to set the threshold, t, separately for
each image. Maybe take the median of the pixel values?

Rupert
Martin Leese...
Posted: Mon May 05, 2008 12:30 pm
Guest
saneman wrote:
Quote:
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?

You need to stuff an example or two on a
website somewhere and post the link.

It sounds like the histogram of each
graytone image will be bi-modal (two lumps).
The goal is to set the value of t to between
the two modes. How you do this depends on
the histograms, particularly on how noisy
they are.

--
Regards,
Martin Leese
E-mail: please at (no spam) see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/
Zeng Fucen...
Posted: Mon May 05, 2008 8:54 pm
Guest
On May 6, 12:08 am, saneman <d... at (no spam) sdf.com> wrote:
Quote:
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?

To decide a good t for each image, you maybe need a adaptive threshold
method. Otsu is a good adaptive method to calculate the t for the
whole image, but shows bad effect on the small object. But if the area
of the characters in your images takes up the main part, Otsu may be a
good method.
GiulioL...
Posted: Wed May 07, 2008 3:51 am
Guest
saneman ha scritto:
Quote:
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?
[sorry for my "english"]

I'm interested in topic, because I'm writing an opensource OCR.
(1) For little samples (single chars) Otsu method is ok.
(2) For entire scanned pages maybe you whish to fix the local white point, before.
If you're interested in (2) I can write more.
Regards,
GiulioL
 
Page 1 of 1       All times are GMT - 5 Hours
The time now is Fri Aug 29, 2008 7:58 pm