Ask Your Question
0

Clean Extra added pixles on contour of text

asked 2016-03-10 03:49:00 -0600

essamzaky gravatar image

In the image in the following link link text

How to clean the outer contour for text , i need to remove the small added pixles , the condition for removing the pixles is that the added pixles width is less than 3 pixles ,so remove pieces which have width one or two pixles only. image description

the red arrows is pointing to some pixles i need to remove from the contour i do not want to add or remove other pixles on the contour , because the geometric of the text will change , the resulted image will be passed to OCR module.

any help is appreciated

edit retag flag offensive close merge delete

Comments

1

Have you tried morphology or blurring? I suggest a 3x3 morphology kernel.

Tetragramm gravatar imageTetragramm ( 2016-03-10 21:14:43 -0600 )edit

Thankx @Tetragramm , yes i had tried the following

morphologyEx(_src,smoothedMat,MORPH_OPEN,getStructuringElement(MORPH_ELLIPSE,Size(3,3)));

The result it better but not the best , because some holes are filled with black , also some regiongs are stucked together , i need to run the filter only on the outer contour of the regions (blobs) and remove only the small variation in the outer contour , i will post the result in an answer to view the result.

essamzaky gravatar imageessamzaky ( 2016-03-13 04:50:33 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-03-13 05:15:16 -0600

essamzaky gravatar image

updated 2016-03-13 05:17:41 -0600

I had used the following code to do smoothing

//smooth the outer contour
    Mat smoothedMat;
    morphologyEx(_src,smoothedMat,MORPH_OPEN,getStructuringElement(MORPH_ELLIPSE,Size(3,3)));
    cv::bitwise_not(smoothedMat,smoothedMat);
    imwrite("c:\\temp\\smoothedMat.tif",smoothedMat);

and the result as the following image description the top right image is the original image the top left image is the smoothed image the bottom image is the combine image to see the diffirence between the two images

the smoothed image is better than the original , but not all pixels in the outer contour are remove , also some holes are filled also some regions (blobs) ar connected togther , is there any better way , to remove the outer noisy pixles without affacting the other pixles.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-03-10 03:49:00 -0600

Seen: 613 times

Last updated: Mar 13 '16