Hi!
I would like to ask your help in a special problem I am fighting with days now:
I have an image, I capture in a given interval. This is an example of it :
https://www.dropbox.com/s/cgh2tpf4hqg6ke5/test.jpg
It might seems a bad quality image, but actually it is in a perfect quality, JUST it is built from stupid "dots". If I invert (-negate) the image, it is much better visible:
https://www.dropbox.com/s/s8htklpx3wvpgtz/test2.jpg
My problem/question is:
- How could I remove the "dots", keeping the numbers quality sharp with imagemagick cmd parameters ?
I need to do this, to make the OCR recognition possible, as it isnt now with these horrible "dots".
All your help would be very much appreciated!
Many Thanks,
Moore
"dots" removal/blur/connect
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: "dots" removal/blur/connect
Blurring will merge pixel colours. I've named your original "dotNumbers.jpg". Windows script, with a bit of processing after the blur:
You'll need to experiment to find what your OCR will accept.
Code: Select all
convert ^
dotNumbers.jpg ^
-blur 0x1.5 ^
-contrast-stretch 50x0%% ^
-unsharp 0x2 ^
dnb.png
snibgo's IM pages: im.snibgo.com
Re: "dots" removal/blur/connect
Thank you for your quick help. I tried it, but it seems, that I can not make it good enough to teh OCR to read.
BUT
May I ask an other quetsion, which could be a perfect work around ?
I have an image style, what is consistent all the time, and tested to work with OCR perfectly:
https://www.dropbox.com/s/xwcayf8c9t6k64p/A.jpg
So, my question is. Is there any "compare" feature of ImageMagick, which could identify if very similar image shown (only numbers are different), and not this ?:
https://www.dropbox.com/s/6wkde7dtrifouy2/B.jpg
BIG thanks for your help, in advance,
Moore
BUT
May I ask an other quetsion, which could be a perfect work around ?
I have an image style, what is consistent all the time, and tested to work with OCR perfectly:
https://www.dropbox.com/s/xwcayf8c9t6k64p/A.jpg
So, my question is. Is there any "compare" feature of ImageMagick, which could identify if very similar image shown (only numbers are different), and not this ?:
https://www.dropbox.com/s/6wkde7dtrifouy2/B.jpg
BIG thanks for your help, in advance,
Moore
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: "dots" removal/blur/connect
I don't understand the question.
I suppose IM could do the OCR work itself, perhaps with "compare" or "-morphology", provided the font and stroke thickness was constant. But that would be quite difficult.
I suppose IM could do the OCR work itself, perhaps with "compare" or "-morphology", provided the font and stroke thickness was constant. But that would be quite difficult.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: "dots" removal/blur/connect
seeIs there any "compare" feature of ImageMagick
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
http://www.imagemagick.org/Usage/compare/#statistics
Re: "dots" removal/blur/connect
Forgive me, if I wasnt clear enough.
So:
Let say, i capture 1 image every second, so 60 image in 1 minute.
59 of them will be similar to this: https://www.dropbox.com/s/6wkde7dtrifouy2/B.jpg
BUT
1 will be similar to this:https://www.dropbox.com/s/xwcayf8c9t6k64p/A.jpg
So, my question:
is there any way to to be able to select this 1 image with some "comapre" feature ?
Many Thanks,
Moore
So:
Let say, i capture 1 image every second, so 60 image in 1 minute.
59 of them will be similar to this: https://www.dropbox.com/s/6wkde7dtrifouy2/B.jpg
BUT
1 will be similar to this:https://www.dropbox.com/s/xwcayf8c9t6k64p/A.jpg
So, my question:
is there any way to to be able to select this 1 image with some "comapre" feature ?
Many Thanks,
Moore
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: "dots" removal/blur/connect
compare successive images until you get one that does not compare favorably. all the rest should give a zero or small error value (rmse).
However perhaps I do not understand. If the images move slightly or are shifted, then the compare will think they are different. So if the camera or the object move, then the compare will fail even though the number are the same, since they will be in different positions.
If it is only a shift and not a scale or rotation, then you could pad one image to twice its size and use the second image as the smaller of the two in a subimage-search mode for compare.
Perhaps you can explain your situation in a bit more detail.
However perhaps I do not understand. If the images move slightly or are shifted, then the compare will think they are different. So if the camera or the object move, then the compare will fail even though the number are the same, since they will be in different positions.
If it is only a shift and not a scale or rotation, then you could pad one image to twice its size and use the second image as the smaller of the two in a subimage-search mode for compare.
Perhaps you can explain your situation in a bit more detail.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: "dots" removal/blur/connect
In general, I would do this:coolice wrote:Let say, i capture 1 image every second, so 60 image in 1 minute. ... is there any way to to be able to select this 1 image with some "comapre" feature ?
Code: Select all
compare -metric RMSE frame_{n}.png frame_{n+1}.png NULL:
I work with video, where the frames are always slightly different, so I adaptively establish a threshold. If your frames are computer-generated, the threshold may be zero.
Other techniques may be possible and more appropriate. In your two examples, the second image contains lots of light grey (almost white); the first contains none.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: "dots" removal/blur/connect
If the one image is different enough, you could just compute the mean of each image successively and difference them and look for sudden changes.Other techniques may be possible and more appropriate. In your two examples, the second image contains lots of light grey (almost white); the first contains none.
convert frame_{n}.png frame_{n+1}.png -format "%[fx:abs(u.mean - v.mean)]" info:
That should be faster than compare -metric rmse.