Ask Your Question
0

Clean Extra added pixles on contour of text

asked Mar 10 '16

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

Preview: (hide)

Comments

1

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

Tetragramm gravatar imageTetragramm (Mar 11 '16)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 (Mar 13 '16)edit

1 answer

Sort by » oldest newest most voted
0

answered Mar 13 '16

essamzaky gravatar image

updated Mar 13 '16

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.

Preview: (hide)

Question Tools

1 follower

Stats

Asked: Mar 10 '16

Seen: 685 times

Last updated: Mar 13 '16