Ask Your Question

# Clean Extra added pixles on contour of text

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.

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 close merge delete

## Comments

1

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

( 2016-03-10 21:14:43 -0500 )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.

( 2016-03-13 04:50:33 -0500 )edit

## 1 answer

Sort by » oldest newest most voted

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 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.

more

Official site

GitHub

Wiki

Documentation

## Stats

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

Seen: 347 times

Last updated: Mar 13 '16