4
\$\begingroup\$

I scanned slides and I have now 48 bit color plus IR (infrared) 16 bit gray files. Now I am processing them to remove dust and scratches and I am looking for a way to batch-detect the correct threshold to apply to IR images to define the regions with dust and scratches. I have over 4k slides and I cannot check all of them manually.

My question is about the choice of an algorithm to define the IR threshold. Other similar questions (Healing dust and scratch marks in scanned photos in post-processing) do not mention the infrared layer, therefore they need to "guess" the dust and the scratches. With the IR channel I have, I know where the issues are, only I have to isolate them better.

I read other questions concerning removal of dust and scratches from scanned film, for example https://stackoverflow.com/questions/27217916/dust-and-scratch-removal-with-open-source-graphic-libraries but those are about the choice of algorithms for the healing, given an already-defined IR B/W mask.

I also prepared some examples to illustrate my issue, I hope they won't clutter the question too much.

By checking the histograms of the IR images of each roll, I notice that I can define a threshold that correctly marks only dust and scratches, without wrongly marking parts of the picture as dust, but this threshold is low and not every scratch gets marked. See first image. I found this is about 135/255, 53% gray.

However, in some images the IR data is distributed around higher brightness values and I would like to increase the threshold to detect more dust. See example 2 where I used either the same threshold as in the first example (first mask) or I used a threshold of 194/255=76% gray (second mask). However, I don't know how to define this new threshold, image by image, automatically.

An option would be to check the slope of the IR histogram? I'm not sure how, there is a lot of variability.

Another option would be to analyse sub-regions of each image and to define a threshold on each one of them to adapt the baseline to brighter and darker regions. However, I am not sure how to define such an algorithm.

I am using G'Mic for the processing due to the very good inpaint filter and it provides a built-in language interpreter. As long as I know which algorithm I should implement, I should have no further problems. This question is specifically about the algorithm and not about its implementation.

The suggestion of other software able to adaptively mark dust and scratches is also welcome, I could pass the result to G'Mic for the final inpaint/healing.

Example 1 Example 2

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Can you make the title of this question actually be a concise summary of the question, in question form? Thanks! \$\endgroup\$
    – mattdm
    Commented Aug 4, 2015 at 13:31
  • \$\begingroup\$ The easiest way to eliminate the dust spots is to clean the slides/negatives before you scan them. That's what pec^pads are created to do. \$\endgroup\$
    – Michael C
    Commented Jan 7, 2016 at 17:52
  • 2
    \$\begingroup\$ Possible duplicate of Healing dust and scratch marks in scanned photos in post-processing \$\endgroup\$
    – Michael C
    Commented Jan 7, 2016 at 17:54
  • \$\begingroup\$ Perhaps you could include the parts of your answer included in both the question and your own answer into a single answer and post it to the already existing question? photo.stackexchange.com/q/25187/15871 \$\endgroup\$
    – Michael C
    Commented Jan 7, 2016 at 17:56
  • 1
    \$\begingroup\$ It's different, I edited my question to clarify. \$\endgroup\$
    – FarO
    Commented Jan 8, 2016 at 12:56

1 Answer 1

2
\$\begingroup\$

A possible algorithm for better isolate the dust and scratches is explained in Comprehensive Solutions for Removal of Dust and Scratches from Images and in Manual Dirt/Scratch Removal Using Infrared Channel (archived version, text-only).

The idea is to remove the shadow of the color information from the infrared image by using the red channel (the one with the wavelength closest to IR) by either simple division of the IR channel by the red channel (second link) or by using linear regression and decorrelation (first link).

At that point the image should be almost clean of the color data and contain almost only defects. Setting a constant threshold becomes feasible.

\$\endgroup\$
3
  • \$\begingroup\$ Too bad the second link does not work anymore. If you have the PDF and if it is redistributable, please share it somewhere. \$\endgroup\$
    – TFuto
    Commented Jan 13, 2016 at 14:59
  • \$\begingroup\$ Updated the answer with a link to text-only version. \$\endgroup\$
    – FarO
    Commented Jan 13, 2016 at 15:12
  • 1
    \$\begingroup\$ I tried to use linear correlation to remove the contribution of the visible (or only of the red) channels from the IR image and the results are basically perfect. \$\endgroup\$
    – FarO
    Commented Jan 21, 2016 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.