Page 1 of 1
Remove white spot
Posted: 2015-09-08T12:58:36-07:00
by gvandyk
Hi
I am busy scanning books with a book scanner using 2 cameras and a central light source. A reflective glass is covering the pages in order to press the pages flat. On all the images the central light leaves a small white spot on the resulting images.
How can this spot be removed?
I need to process thousands of pages, and the spot is not always in the same place, so I would need some generic way of removing the spot.
Here is an example of one of the images:
https://www.dropbox.com/s/fjqqpbk8r8e2xjo/spot.jpg
Thanks
Re: Remove white spot
Posted: 2015-09-08T18:16:36-07:00
by fmw42
What is your version of IM and platform?
If on Unix, try using my script, textcleaner, to make the whole background white. That should make your white spot blend into the white background.
Otherwise, try IM
Code: Select all
convert image -negate -lat 20x20+10% -negate result
to achieve something similar.
Re: Remove white spot
Posted: 2015-09-08T23:32:42-07:00
by gvandyk
HI
Thank you very much, that works well when I convert the image to do text extraction etc, and thank you very much, we are already using your script.
But: We need to provide the original color image as well, as these are very old artefacts dating back to the mid 18:00 in some cases. There are markings on the paper and the authenticity needs to be kept on the originals.
Re: Remove white spot
Posted: 2015-09-09T00:06:03-07:00
by snibgo
It may be difficult to remove automatically, without leaving a trace.
Do you have a better quality image? JPEG introduces junk and makes the problem even more difficult.
Re: Remove white spot
Posted: 2015-09-09T01:22:35-07:00
by gvandyk
Unfortunately the JPEG is the only image that we have currently. The cameras only produce JPEG.
We don't mind leaving a little trace on the image, as this is understandable, but the spot needs to "almost" disappear.
Re: Remove white spot
Posted: 2015-09-10T09:25:40-07:00
by gvandyk
I can get the area that should be changed with the -threshold parameter.
convert input.jpg -threshold 87% -negate output.png
The next hurdle to overcome would be, is to make those pixels under the "threshold" black area to be X % darker.
I've managed to replace those pixels by a different color, but I don't know how to darken the pixels relative to the "brightness" of the pixels.
Any ideas?
Re: Remove white spot
Posted: 2015-09-10T09:53:49-07:00
by fmw42
see -mask at
http://www.imagemagick.org/Usage/masking/#special_masks and -brightness-contrast at
http://www.imagemagick.org/script/comma ... s-contrast
Code: Select all
convert input.jpg -threshold 87% -negate mask.png
convert input.jpg -mask mask.png -brightness-contrast X,Y +mask result.png
or
Code: Select all
convert input.jpg \
\( -clone 0 -threshold 87% -negate -write mpr:mask +delete \) \
-mask mpr:mask -brightness-contrast X,Y +mask result.png
Re: Remove white spot
Posted: 2015-09-10T11:22:53-07:00
by gvandyk
Thanks Fred
I eventually used 83% for threshold, 23 for brightness and -50 for contrast. The spot is much less and are within the acceptable parameters.
So the following is working ok:
Code: Select all
convert input.jpg \
\( -clone 0 -threshold 83% -negate -write mpr:mask +delete \) \
-mask mpr:mask -brightness-contrast 23,-50 +mask result.png