Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
3.33/5 (2 votes)
i want a java code to can take an image taken in bad brightness condition and correct it to can recognize some numbers written on it

the image i worked on has more light at left of it and dark at right

is there any algorithm to do this

Note. there is not the only case i will face i want to deal with any image with any case and correct it.

i tried to divide the image into parts and correct part part by get rgb for all pixel add all and divide by numbers of pixels and this will be my threshold to convert the image to black and white binary image to detect numbers but the result is sooo bad and i can detect alot of numbers

is there a way to do this?

Note. i really don't want to use any external library as i will use this pc java code to create a big android project
Posted
Comments
AlphaDeltaTheta 17-May-13 21:59pm    
I suggest to use jai, rather than reinventing the wheel it's better to improve one. Image correction algorithms are difficult to make and even more difficult to run. Imagine a single mistake in coding causing a memory leak or taking years to process a single image! 3rd party libs are tested and optimized why to go into hassle!
amir tarek 19-May-13 4:05am    
so what library i can use?

1 solution

Amir,

what you want to achieve is called shading correction, or flat-field correction. There are several ways to do that, depending on the exact problem statement.

One approach is possible when you know the illumination field in advance. I mean if you can take a picture of a white sheet under exactly the same lighting. Then, dividing the values in your image by the reference illumination will restore constant illumination, i.e. flat-field.

If you can't use this approach, then you'll need to do some kind of background reconstruction, i.e. try and re-create the reference illumination. Usually the non-uniformity of lighting has smooth and slow variations and corresponds to spatial frequencies that are much longer than those of the printed text. So a lowpass filter is called for. It will erase the text and keep the background. [your proposed approach is not so different but it will introduce discontinuities.]

In the first place, you can try a Gaussian filter of a large variance, and subtract (or divide) the blurred image from the original.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900