Ask Your Question

How to Crop image after extract text in JAVA

asked 2017-02-06 12:19:46 -0500

Wanipook gravatar image

updated 2017-02-07 05:05:20 -0500

I'm trying to use android-opencv to recognize text in the picture and I want to do something like finding blocks of text in an image and crop them.

After croping image I will get some of text image and I plan to use them to do OCR in the future. For now I can detect the text regien in the image already by useing this algorithm guide from this link

* My problem is I do not know how to Croping image after extracting text in java language. *

In my concept, I will crop the image from top to button and from left to right. After that put all of croped image in an array of MAT (I'm not sure that MAT function can do the array or not) [see my concept picture]

I do not know how to deal with them. Could anyone please help me, guide me, or give me some advice please ... Thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-10-12 12:12:22 -0500

holger gravatar image

If it is really only about cropping - try this

//crops an image starting on top left with 100pixels width and height
Mat img = imread("myimage.jpg")
Rect roi = new Rect(0, 0 , 100, 100)
Mat cropped = new Mat(img, roi)
imwrite("cropped.jpg", cropped)
edit flag offensive delete link more


again from 2017...

holger gravatar imageholger ( 2018-10-12 12:13:20 -0500 )edit

... and if you read between the lines, sorting the rects by x,y was the main problem here, imho.

berak gravatar imageberak ( 2018-10-13 01:04:25 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-02-06 12:19:46 -0500

Seen: 2,160 times

Last updated: Oct 12 '18