First time here? Check out the FAQ!

Ask Your Question
0

thresholding image in java

asked Apr 9 '13

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!

Preview: (hide)

1 answer

Sort by » oldest newest most voted
0

answered Apr 9 '13

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

Preview: (hide)

Question Tools

Stats

Asked: Apr 9 '13

Seen: 3,300 times

Last updated: Apr 09 '13