Results 1 to 4 of 4
Thread: Turning an image to binary
- 01-17-2010, 01:09 AM #1Member
- Join Date
- Nov 2009
- Rep Power
- 01-17-2010, 02:16 AM #2
i would guess a good start would be to 'poster-ize' the image sample, that is to reduce its color depth
I remember something from my academic years where scanning each pixel and observe the color of the adjacent pixels and if the majority of them are darker then this pixel becomes black and if the majority are lighter, this one becomes white. have a look at the "GIMP" (a desktop application,but they have some fun transforms such as this posterize feature.
another thing to consider today, is how much granularity do we want to quantize the image in. back in the day when digital cameras only had a resolution of about 100 to 300 pixels, it was straight forward to create a recursive algorithm, or even a bunch of for() loops to scan each pixel in the image and it would work within a reasonable amount of time. Now that the cameras of today have thousands of pixels by thousands of pixels, the amount of processing time required to transform an entire image pixel by pixel can become quite huge.
One approach is to create a 'software pixel', where you block the image out in groups of pixels, say 4x4 . and take an average value of all the pixels to mean the value of the one pixel. Now for hand writing this might need some playing with to find what the good amount of grouping pixels is with the resolution of your input digital image, but the the coarser the quantized input data is into the neural network, the easier it is to start working with it right, and the less chance of it intepreting small hand writing artifacts as parts of the characters.
Now, for specific code or algorithms, I don't have any for these yet, but hoping these high level concepts are a good place to start for ideas.
- 01-17-2010, 03:12 AM #3Member
- Join Date
- Nov 2009
- Rep Power
Thanks for answer.
What I do at the moment is:
1. change the image colors to grey scale
2.check pixel by pixel if it's darker then neighbours (to set frames around digits)
3.cut each digit
4.check each pixel if it's lighter than average of 10 pixels taken form the image.
If it is then change it's colour to white, else change it to black
It doesn't work slow, but the problem is when I have a high resolusion photo with noise then my algorithm fails.
- 01-17-2010, 08:47 PM #4
hmm, that removal of noise from the image is a bit out of my expertise.
There seems to be a lot of work in this field, certainly no shortage of patents
Like this page:
Keith Price Bibliography Noise Removal, Impulse Noise
some of them even older.
My thoughts, based on your current approach to average out pixels, what if you supplied a second step of averaging again after the first step, where you apply a weighting to the dark pixels based on how many continuous adjacent ones are. the theory being that smaller isolated spots might be the noise, and not part of a continous pen stroke that is part of a character.
- By Deva in forum New To JavaReplies: 4Last Post: 12-24-2009, 05:49 PM
- By Deva in forum New To JavaReplies: 3Last Post: 12-24-2009, 05:48 PM
- By shakall in forum SWT / JFaceReplies: 3Last Post: 12-22-2009, 02:50 PM
- By hyz_zsu in forum Java 2DReplies: 1Last Post: 04-09-2009, 03:14 AM
- By nupurashi in forum Advanced JavaReplies: 4Last Post: 04-01-2009, 07:27 PM