In the mid 70's I wrote an APL function to threshold and de-speckle 
grayscale images from a handheld video camera, which was  used to read 
the price tags on store merchandise (OCR Wand). The algorithm was 
eventually coded in assembly, and implementer in the commercial product. 
This was before barcodes became common.

The thresholding algorithm looked at the surrounding cells of each pixel 
(usually a 3x3 , 5x5, ot 7x7 square depending on the character and line 
resolution), and did several steps.
1) It turned the pixel black if the pixel was significantly darker than 
the average of all the local pixels (part of a character)
2) It turned the pixel white if the pixel was significantly lighter than 
the average of all the local pixels (not part of a character)
3) It turned the pixel white if there were few surrounding dark pixels 
(fly speck)

I found that looking at local averages for pixel decisions worked better 
than thresholding by looking at the overall average of the whole image, 
since gradual shading across the image could throw off the thresholding 
process. I don't have the APL code anymore (it was developed on a IBM 
Selectric typewriter with an acoustic coupler). However the J version of 
Conway's Game of Life uses a very similar scheme, looking at the cells 
surrounding a specific cell, to make a decision on that cell's state. 
Cliff Reiter has his Life code at:
http://ww2.lafayette.edu/~reiterc/j/vector/vlife2.html

Skip Cave
.
.
.
PackRat wrote:
> I have a very large number of scanned textual grayscale images where I 
> want to make the background white rather than a range of white to gray 
> (due to paper bends and other variations) as well as to darken the 
> black text a bit.  (It would be far too labor-intensive to manually 
> adjust each image, one by one, with photo editing software.)
>
> Does anyone know if there is any J code or (preferably) a J control 
> where one can easily adjust the white point and black point on the 
> histogram of an image, seeing the image display change as the values 
> are changed?  (The white point is where every value from there upward 
> to the maximum is converted to white, and, conversely, the black point 
> is where every value from there downward to the minimum is converted to 
> black.)
>
> I didn't see anything like this in Cliff Reiter's book, although he 
> does work a little with image histograms.
>
> It would be even nicer if this could be also scripted in some way to 
> automatically go through a series of images using two predetermined 
> values.
>
> Thanks in advance!
>
> Harvey
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>
>   
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to