Ask Your Question
0

Dropout red color and binarize image (Android)

asked 2016-09-09 04:44:58 -0500

Atado gravatar image

Hey, im new to OpenCV and i'd like to use it in my Android Application.

In the app i have to process some images of transactions like this: Example image

I want to filter/dropout the red form color and then binarize the image.

Later i need some OCR to recognize some numbers in the footer etc. so thought i use this to improve the quality of the image:

Imgproc.morphologyEx(mat, mat, Imgproc.MORPH_OPEN, Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(2, 2)));
    Imgproc.morphologyEx(mat, mat, Imgproc.MORPH_CLOSE, Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(2, 2)));

The opening should remove the noise in the image and the closing after should improve the written values on the image.

Im not sure tho whats the best way to accomplish the first part (filtering the red form color and binarizing the image). Hope you can give me some tips.

Best regards

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-09-09 05:56:47 -0500

Filtering that reddish color can be done fairly easy

  • Transfer image to HSV color space
  • Make sure that the H channel is in the range 0-50 or 310-360
  • Make sure that V is in the range of 0.3-1
  • The final combined mask will probably have the reddish colors
  • Now apply a mask and set that mask to white, then merge both images together.

Threshold/range values found here:

image description

edit flag offensive delete link more

Comments

Thanks alot for your answer. I think i managed to implement the first 4 steps but im stucking at the last one. Im not really sure what u mean with "Now apply a mask and set that mask to white, then merge both images together." Hope you can help me. Best regards

Atado gravatar imageAtado ( 2016-09-12 04:51:39 -0500 )edit

In the last stage that succeeded you ended up with a binary image, the mask. where 1 should be the pixels to keep and 0 to ignore. If so, then you can simply do and AND between the input image channels and the mask, to have a resulting color image.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-09-12 04:56:17 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-09-09 04:44:58 -0500

Seen: 489 times

Last updated: Sep 09 '16