I want to remove spots from the image shown below. I have tried using Imagemagick's convert function, but the black spots are not removed. I need a cleaner image with bold date showing.
Asked
Active
Viewed 340 times
0
-
You can try something similar to [this](https://stackoverflow.com/questions/48177052/how-to-remove-the-noise-in-the-given-image-so-that-the-ocr-output-be-perfect) answer – Dmitrii Z. Jan 21 '18 at 16:46
2 Answers
1
In Imagemagick, you can remove the spots using connected components and optionally morphology. For example the following removes 2 pixel isolated spots or less. The morphology fills in some of the dark part of the text (it removes or opens the white background). But it may make some of the characters merge (touch):
Input:
convert spots.png \
-threshold 1% -type bilevel \
-define connected-components:area-threshold=2 \
-define connected-components:mean-color=true \
-connected-components 4 \
spots_clean.png
convert spots.png \
-threshold 1% -type bilevel \
-define connected-components:area-threshold=2 \
-define connected-components:mean-color=true \
-connected-components 4 \
-morphology open diamond:1 \
spots_clean_o1.png
convert spots.png \
-threshold 1% -type bilevel \
-define connected-components:area-threshold=2 \
-define connected-components:mean-color=true \
-connected-components 4 \
-morphology open octagon:1 \
spots_clean_o2.png

fmw42
- 46,825
- 10
- 62
- 80
-
really thanks for your reply but little bit issue still is that forward slash after 08 these forward salsh little bit can we complete get similar like after 04 is it possible? – Dhaval Bhavsar Jan 22 '18 at 11:02
-
I do not know how to fill that forward slash in. It is that way in your input image. Further attempts with larger morphology filters will bleed the characters together or fill in the circles in the 8 characters. – fmw42 Jan 22 '18 at 18:54
0
I think there is no "easy" way to do this. But :
You can iterate over all pixels of the image and check this:
- if the current pixel is black : check all neighbourg pixels.
- if all neightbourg pixels are white, change current pixel to white.
A better way, but longer way, is to use an OCR, to recognize the numbers and characters. Then rebuild the image with the characters found.

Syscall
- 19,327
- 10
- 37
- 52