A few problems removing large dots
Posted: 2017-09-04T07:54:16-07:00
Hi, I'm trying to clean up this image for OCR.
https://ibb.co/bRK8ia
First I used lat to clean up most of the noise. I also tried canny and it works very well but I do not know how to fill the empty letters (I tried EdgeIn/Out with no luck).
Now I need to select the large dots forming the horizontal lines, my main problem. I tried with a 6x6 kernel and it works
convert temp-inv.png \( +clone \
-morphology HMT "6: 0,0,0,0,0,0 0,-,-,-,-,0 0,-,1,1,-,0 0,-,1,1,-,0 0,-,-,-,-,0 0,0,0,0,0,0" \
-morphology Dilate Ring \
-background red -alpha shape \
\) -composite x:
but now I do not know how to remove the selected dots. I tried to use this:
convert temp-inv.png -morphology HMT "6>: 0,0,0,0,0,0 0,-,-,-,-,0 0,-,1,1,-,0 0,-,1,1,-,0 0,-,-,-,-,0 0,0,0,0,0,0" lines-thin.png
to extract the lines only and laters subtract these but the dots I get are very thin and I was not able to make them larger with Thicken (with unity, square, hullconvex,...). I also do not like the idea of Thickening the dots, I'd prefer just to subtract the original matching pixels the were selected in the first stage.
So I'd like to use something different from HMT to extract the pixels that match the kernel. Is there something like that?
I also have a few dots missing that are smaller than 6x6 and I do not know if the correct route is to add a few more kernels (6x5, 5x4, 6x4, etc.) or if there is a better alternative to remove small dust (I tried median and it works quite well). I tried to use the Gaussian kernel expecting to be able to select a single round "blob" but the whole image is always selected.
I also tried open/close to remove small dots with worst results.
Thanks for any help/suggestions.
https://ibb.co/bRK8ia
First I used lat to clean up most of the noise. I also tried canny and it works very well but I do not know how to fill the empty letters (I tried EdgeIn/Out with no luck).
Now I need to select the large dots forming the horizontal lines, my main problem. I tried with a 6x6 kernel and it works
convert temp-inv.png \( +clone \
-morphology HMT "6: 0,0,0,0,0,0 0,-,-,-,-,0 0,-,1,1,-,0 0,-,1,1,-,0 0,-,-,-,-,0 0,0,0,0,0,0" \
-morphology Dilate Ring \
-background red -alpha shape \
\) -composite x:
but now I do not know how to remove the selected dots. I tried to use this:
convert temp-inv.png -morphology HMT "6>: 0,0,0,0,0,0 0,-,-,-,-,0 0,-,1,1,-,0 0,-,1,1,-,0 0,-,-,-,-,0 0,0,0,0,0,0" lines-thin.png
to extract the lines only and laters subtract these but the dots I get are very thin and I was not able to make them larger with Thicken (with unity, square, hullconvex,...). I also do not like the idea of Thickening the dots, I'd prefer just to subtract the original matching pixels the were selected in the first stage.
So I'd like to use something different from HMT to extract the pixels that match the kernel. Is there something like that?
I also have a few dots missing that are smaller than 6x6 and I do not know if the correct route is to add a few more kernels (6x5, 5x4, 6x4, etc.) or if there is a better alternative to remove small dust (I tried median and it works quite well). I tried to use the Gaussian kernel expecting to be able to select a single round "blob" but the whole image is always selected.
I also tried open/close to remove small dots with worst results.
Thanks for any help/suggestions.