<html>
<head>
<meta content="text/html; charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<pre>Hi Michael,
I found this thread in the SANE mailing list archive.
I already implemented ir scan for my CS9000F (pixma backend).
Now I'm searching an open source program and/or lib for processing ir data
against the rgb scan. Fortunately my scanner provides pure dust images without
any shadows from the negatives/slides.
Did you started with implementing your code in sanei and/or can I reuse your
code from <i><a href="http://wwwuser.gwdg.de/%7Emrickma/sane-proscan-7200/status-110711/">http://wwwuser.gwdg.de/~mrickma/sane-proscan-7200/status-110711/</a></i>
and/or do you have newer code and/or can you please provide your experiences
with dust removing?
Many thanks for your help in advance.
Cheers,
Rolf
</pre>
<br>
<br>
<br>
<div class="moz-cite-prefix">Am 11.07.2011 17:03, schrieb m. allan
noah:<br>
</div>
<blockquote cite="mid:51C9EBF5.6000404@fam-bensch.de" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-15">
<pre>Excellent description of both the problem, and the solution. I wrote
sanei_magic to contain exactly these sort of routines. Though, you
could also add a sanei_ir or some such, if you want a more 'private'
playground :)
allan
On Mon, Jul 11, 2011 at 12:54 PM, Michael Rickmann <<a moz-do-not-send="true" href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel">mrickma at gwdg.de</a>> wrote:
><i> I learned from other posts in this list that SANE does not provide much
</i>><i> support for infrared. In sane.h some related definitions are even commented
</i>><i> out. Only in coolscan.c I have found some RGBIfix routines by Andreas Rick
</i>><i> which must be related to what he describes on his page at
</i>><i> <a moz-do-not-send="true" href="http://andreas.rick.free.fr/sane/dustremove.html.">http://andreas.rick.free.fr/sane/dustremove.html.</a> With my attempts to
</i>><i> support PIE film scanners in the pie backend I have reached a stage where I
</i>><i> can receive R, G, B and I color planes at resolutions from 300 to 3600 dpi
</i>><i> at 16 bit color depth. I wish to use the infrared channel for dirt removal
</i>><i> without touching current SANE specifications. Essentially three things have
</i>><i> to be done:
</i>><i> 1) reduce red spectral overlap from the infrared (ired) plane
</i>><i> 2) find the dirt
</i>><i> 3) replace the dirt
</i>><i> Everything beyond depends on the kind of film and taste. If you are
</i>><i> interested in quick results skip down to the last paragraphs of this post.
</i>><i> I rolled up my sleeves though in a different way than suggested on this list
</i>><i> and made a small program ircleanest.c in which I tried to implement above
</i>><i> three steps. For trying image calculations before programming "ImageJ"
</i>><i> (<a moz-do-not-send="true" href="http://rsbweb.nih.gov/ij/">http://rsbweb.nih.gov/ij/</a>) has been great help.
</i>><i>
</i>><i> Ad 1) Quite often the ired image looks like a greyscale image with dirt
</i>><i> emphasized. Something similar was reported for the Epson V700 scanner in (
</i>><i> <a moz-do-not-send="true" href="http://lists.alioth.debian.org/pipermail/sane-devel/2011-February/028149.html">http://lists.alioth.debian.org/pipermail/sane-devel/2011-February/028149.html</a>
</i>><i> ). The ired plane of negative films usually only contains slight shades of
</i>><i> the image but slide films may show a considerable amount of it. I tried
</i>><i> something with gamma and linear operations what Andreas Rick describes for
</i>><i> the Coolscan. I could not get it to work and I do not wish to craft
</i>><i> parameters by hand for every slide.
</i>><i> When plotting the ired value of 1000 randomly chosen pixels against the red
</i>><i> value the relation ired = b + a * ln (red) always gave a good fit. So
</i>><i> calculating an ired' = ired - a * ln (red) should clean the ired plane. It
</i>><i> works. I randomly sample 2000 pixels, calculate the parameter "a" by linear
</i>><i> regression from the ln (red) and ired values, produce an ired' plane and
</i>><i> scale it between 0 and 65535. I also tried to include green and blue planes
</i>><i> but there is a lot of calculation and no real benefit. A similar cleaning
</i>><i> effect one gets with the relations ired = b * red ^ a and ired' = ired / red
</i>><i> ^ a. This comes closer Andreas Rick's suggestion of applying a gamma, and
</i>><i> the coefficients can also be determined by linear regression.
</i>><i>
</i>><i> Ad 2) First I tried static thresholds to find the dirt. I still use two of
</i>><i> them, Otsu's and Yen's in M. Emre Celebi's implementation in the FOURIER 0.8
</i>><i> project ( <a moz-do-not-send="true" href="http://sourceforge.net/projects/fourier-ipal">http://sourceforge.net/projects/fourier-ipal</a> ). Yen's threshold in
</i>><i> this implementation assumes a bimodal distribution and was the best of the
</i>><i> static thresholds I tried in detecting only dirt. I still use it to add
</i>><i> large dirty areas. But soon I gave up detecting smaller dirt with static
</i>><i> thresholding without user intervention. On my search for an adaptive
</i>><i> threshold I stumbled over the MAD (median of the absolute deviations from
</i>><i> the median) filter (Crnojevic V. (2005) "Impulse Noise Filter with Adaptive
</i>><i> Mad-Based Threshold. Proc. of the IEEE Int. Conf. on Image Processing, 3:
</i>><i> 337-340). It is an understandable paper describing an algorithm of rather
</i>><i> low complexity. Median filtering, however, is rather slow. First, I
</i>><i> replaced the first median filter step of the original paper with a maximum
</i>><i> filter because the dirty pixels are always darker than the real signal. Then
</i>><i> I managed to get images from the scanner at maximum resolution and realized
</i>><i> some impulse noise. So I resorted to a mean filter. The second median I also
</i>><i> replaced by a mean filter to reduce computation time. In spite of these
</i>><i> changes Crnojevic's recommendations for the choice of the parameters "a" and
</i>><i> "b" were still valid when scaled to 16 bit. In my ircleanest.c program it is
</i>><i> the filter_madmean routine. Combining the madmean dirt mask with the one
</i>><i> from Yen's static threshold gave a good representation of what I felt had to
</i>><i> be removed.
</i>><i>
</i>><i> Ad 3) For Replacing the dirt I dilate the clean image parts into the dirty
</i>><i> ones. As I wish to do that in one sweep several pixels deep I first
</i>><i> calculate the Manhattan distance of dirty pixels to their closest clean
</i>><i> neighbors and keep an index of these clean ones. The result is ok in general
</i>><i> but looks funny when the original dirt was overlapping a region of high
</i>><i> colour changes. So I adapt the dilated pixels by a mean filter to their new
</i>><i> surroundings and replace them again. Clean pixels remain unchanged by this
</i>><i> procedure.
</i>><i>
</i>><i> You find examples of my dust removal at
</i>><i> <a moz-do-not-send="true" href="http://wwwuser.gwdg.de/%7Emrickma/sane-proscan-7200/status-110711/">http://wwwuser.gwdg.de/~mrickma/sane-proscan-7200/status-110711/.</a> The
</i>><i> ircleanest.c is in the files.tar.gz. All you have to tell ircleanest is the
</i>><i> resolution at which the scan was taken. An approximately 5 year old Pentium
</i>><i> 4, 3.40GHz needs about 14 secs to clean a 4979 * 3330 image (slide scanned
</i>><i> at 2700 dpi) though gprof reports only 5.09 secs. A two year old Phenom x4
</i>><i> 64-bit needs 7 - 8 secs with gprof reporting about 4.75 secs.
</i>><i>
</i>><i> Would code for dirt removal be acceptable in a SANE backend or in
</i>><i> sanei_magic?
</i>><i> Regards
</i>><i> Michael
</i>><i>
</i>><i>
</i>><i> --
</i>><i> sane-devel mailing list: <a moz-do-not-send="true" href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel">sane-devel at lists.alioth.debian.org</a>
</i>><i> <a moz-do-not-send="true" href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel</a>
</i>><i> Unsubscribe: Send mail with subject "unsubscribe your_password"
</i>><i> to <a moz-do-not-send="true" href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel">sane-devel-request at lists.alioth.debian.org</a>
</i>><i>
</i></pre>
</blockquote>
<br>
</body>
</html>