Ask Your Question
0

thresholding image in java

asked 2013-04-09 08:30:35 -0600

kicho gravatar image

Hi!

i'm pretty much new with opencv, started few days ago, and i would like to use opencv in image preprocessing for OCR. I have an image that represents a payment order (printed mainly in some kind of red) filled with typed text (black). My goal (for now) is to create an image that contains only typed text. Iterating through pixels doesn't seem as a solution, i guess it would be pretty much slow. so i guess some kind of thresholding would do the trick. but, the problem is i don't know how to do it. To be more precise, i don't know how to define threshold..

So far i've got this:

Mat image = Highgui.imread("file.jpg",Highgui.CV_LOAD_IMAGE_UNCHANGED);
Mat imageHSV = new Mat(image.size(), image.type());
Imgproc.cvtColor(image, imageHSV, Imgproc.COLOR_BGR2HSV);

At this point i should have HSV image. Now i should define a mask (or threshold)?

Mat mask = ???

and then i should use something like this

Core.inRange(imageHSV, scalarLower, scalarUpper, mask);

Some help would be appreciated... Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-04-09 09:19:17 -0600

Basically this guide tells you how thresholding works, but this is in the old C-style API.

http://8a52labs.wordpress.com/tag/thresholding-images-in-opencv/

After reading through it, to get the grasp of it, look at this for the C++ interface, which is much easier to handle.

http://docs.opencv.org/modules/imgproc/doc/miscellaneous_transformations.html?highlight=threshold#cv.Threshold

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-04-09 08:30:35 -0600

Seen: 3,260 times

Last updated: Apr 09 '13