Ask Your Question
-1

extracting a rectangle containing texts

asked 2018-05-29 09:05:41 -0500

aniskraini@yahoo.fr gravatar image

I wanted to know how I can extract a rectangle added to an image that contains text. Thank you very much in avanceimage description. for exemple i need to extract the blue rectange" PRIMAIRE: LES ECARTS SE RESSERRENT"

edit retag flag offensive close merge delete

Comments

what have you tried, so far ?

(right now, it's only another "i want" question, showing no research, skill or effort)

berak gravatar imageberak ( 2018-05-29 10:18:28 -0500 )edit

I try many algorithme, detection of text and morphlogy segmentation.

int main() {

Mat large = imread("result.png");

Mat rgb;    // downsample and use it for processing    pyrDown(large, rgb);

Mat small;

cvtColor(rgb, small, CV_BGR2GRAY); // morphological gradient

Mat grad;

Mat morphKernel = getStructuringElement(MORPH_ELLIPSE,    Size(3, 3));

morphologyEx(small, grad, MORPH_GRADIENT, morphKernel);

// binarize
Mat bw; threshold(grad, bw, 0.0, 255.0, THRESH_BINARY | THRESH_OTSU);
// connect horizontally oriented regions Mat connected;
morphKernel = getStructuringElement(MORPH_RECT, Size(9, 1));
morphologyEx(bw, connected, MORPH_CLOSE, morphKernel);
// find contours Mat mask = Mat::zeros(bw.size(), CV_8UC1);

aniskraini@yahoo.fr gravatar imageaniskraini@yahoo.fr ( 2018-05-30 02:59:35 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-05-30 05:02:03 -0500

berak gravatar image

maybe you want to give the dnn based text detection (in latest opencv) a try:

image description

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-05-29 09:05:41 -0500

Seen: 68 times

Last updated: May 30 '18