OpenCV - Removal of noise in image

后端 未结 9 1614
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 01:01

I have an image here with a table.. In the column on the right the background is filled with noise

How to detect the areas with noise? I only want to apply some kind of

相关标签:
9条回答
  • 2021-02-04 01:38

    If processing time is not an issue, a very effective method in this case would be to compute all black connected components, and remove those smaller than a few pixels. It would remove all the noisy dots (apart those touching a valid component), but preserve all characters and the document structure (lines and so on).

    The function to use would be connectedComponentWithStats (before you probably need to produce the negative image, the threshold function with THRESH_BINARY_INV would work in this case), drawing white rectangles where small connected components where found.

    In fact, this method could be used to find characters, defined as connected components of a given minimum and maximum size, and with aspect ratio in a given range.

    0 讨论(0)
  • 2021-02-04 01:41
    • Blur (3x3 box)
    • Threshold at 127

    Result:

    0 讨论(0)
  • Try thresholding the image like this. Make sure your src is in grayscale. This method will only retain the pixels which are between 150 and 255 intensity.

    threshold(src, output, 150, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);
    

    You might want to invert the image as you are trying to negate the gray pixels. After the operation, invert it again to get your desired result.

    0 讨论(0)
提交回复
热议问题