Removing "green shadow" caused by flatbed scanner
Posted: 2013-11-26T14:46:55-07:00
Version: ImageMagick 6.6.2-6 2011-04-02 Q16 (as far as I can go on this OS)
Platform: Ubuntu Linux
API: shell command line
Thanks for the help with getting the black background right and the stamps not piling on top of each other....
viewtopic.php?f=1&t=24509
Now my problem is the "green shadow" (I am scanning on green background for "green screen" purposes) that is an artifact of using a flatbed scanner. One side (or more than one side it the stamp is at an angle) shows a shadow (in the original and in the result) that is caused by the way the scanner lights the subject and the fact that a stamp does have thickness, thus a shadow is created. After processing with the script, the shadow is still somewhat present and I have not been able to make it go away. If I manually color-select in Gimp, I can select all the shadow areas and fill them with black, with good result -- but that is much more time consuming than not using the whole background removal script in the first place.
(The reason/need for "background removal" is that the the stamps often have black postmarks on them that go to the edge of the stamp, which, when manually filling background with black, "eats into" the stamp. Thus I am experimenting with "green screen" or "chroma key" scanning on a colored background ... so that I can automatically process a large number of these images to fill the backgrounds with solid black.)
I am now using the bg_removal script from the IM website WITH MODFICATION of the background setting thanks to Fred (no other modifications yet). The script I am using is here:
http://jsa.viewimage.net/temp/im/bg_rem ... modified.s
The source file coming from the scanning process is here:
*** I am posting a JPEG version for easy web viewing purposes.
http://jsa.viewimage.net/temp/im/source.jpg
*** The original TIFF version is here:
http://jsa.viewimage.net/temp/im/source.tif (5.5 MB)
The current result of the script process is here -- you really have to magnify the image to see the problem (the green shadows along the tops of the stamps' perforations):
http://jsa.viewimage.net/temp/im/result-2.tif (5.5 MB)
The command line is:
sh bg_removal_js-modified.s -n source.tif 30 7 result-2.tif
The -n (normalize) does not seem to make a difference one way or the other.
The 30 is the "fuzz out" (the pixels that will be classified as background). I have played with this number and up to a point (10?) increasing it helps reduce the "green shadow" but past a point increasing the number seems to have no effect.
The 7 is the "fuzz in" (the pixels that will be classified as foreground and which are part of the desired final image). Any higher than 7 and the black background starts to "eat into" the stamp area. Any less and the green shadow increases.
One off-the-wall idea I have, but absolutely do not have the skills to even know where to begin, to say nothing to executing it, is to create an image that represents the gradient of color in the shadow area of the original source. Then have the script include ALL the colors in that gradient (that are in the gradient zone, but not in the stamp itself) in the color(s) that the script is including in the background. However, somehow that approach seems very complicated and backwards.
I have yet to see a scanner that does not cause this problem. Scanners seem to be made to scan images/text ON an object (paper) instead of scanning the object itself (a stamp).
I welcome any suggestions.
Platform: Ubuntu Linux
API: shell command line
Thanks for the help with getting the black background right and the stamps not piling on top of each other....
viewtopic.php?f=1&t=24509
Now my problem is the "green shadow" (I am scanning on green background for "green screen" purposes) that is an artifact of using a flatbed scanner. One side (or more than one side it the stamp is at an angle) shows a shadow (in the original and in the result) that is caused by the way the scanner lights the subject and the fact that a stamp does have thickness, thus a shadow is created. After processing with the script, the shadow is still somewhat present and I have not been able to make it go away. If I manually color-select in Gimp, I can select all the shadow areas and fill them with black, with good result -- but that is much more time consuming than not using the whole background removal script in the first place.
(The reason/need for "background removal" is that the the stamps often have black postmarks on them that go to the edge of the stamp, which, when manually filling background with black, "eats into" the stamp. Thus I am experimenting with "green screen" or "chroma key" scanning on a colored background ... so that I can automatically process a large number of these images to fill the backgrounds with solid black.)
I am now using the bg_removal script from the IM website WITH MODFICATION of the background setting thanks to Fred (no other modifications yet). The script I am using is here:
http://jsa.viewimage.net/temp/im/bg_rem ... modified.s
The source file coming from the scanning process is here:
*** I am posting a JPEG version for easy web viewing purposes.
http://jsa.viewimage.net/temp/im/source.jpg
*** The original TIFF version is here:
http://jsa.viewimage.net/temp/im/source.tif (5.5 MB)
The current result of the script process is here -- you really have to magnify the image to see the problem (the green shadows along the tops of the stamps' perforations):
http://jsa.viewimage.net/temp/im/result-2.tif (5.5 MB)
The command line is:
sh bg_removal_js-modified.s -n source.tif 30 7 result-2.tif
The -n (normalize) does not seem to make a difference one way or the other.
The 30 is the "fuzz out" (the pixels that will be classified as background). I have played with this number and up to a point (10?) increasing it helps reduce the "green shadow" but past a point increasing the number seems to have no effect.
The 7 is the "fuzz in" (the pixels that will be classified as foreground and which are part of the desired final image). Any higher than 7 and the black background starts to "eat into" the stamp area. Any less and the green shadow increases.
One off-the-wall idea I have, but absolutely do not have the skills to even know where to begin, to say nothing to executing it, is to create an image that represents the gradient of color in the shadow area of the original source. Then have the script include ALL the colors in that gradient (that are in the gradient zone, but not in the stamp itself) in the color(s) that the script is including in the background. However, somehow that approach seems very complicated and backwards.
I have yet to see a scanner that does not cause this problem. Scanners seem to be made to scan images/text ON an object (paper) instead of scanning the object itself (a stamp).
I welcome any suggestions.