Feature Request: Dust & Scratches filter

Issue #169 new
Michael Ezra created an issue

This would be a welcome addition - Dust & Scratches filter for cleaning up the film scans.

Would be great to have access to masking selections.

What would be also interesting, is to account for the fact that dust and scratches on film/print scans may have a higher degree of sharpness than the content of the image. So, additional masking with the focus mask (algorithm already built in in RT/ART) may provide a greater degree of control to isolate the dust & scratches from the image detail.

Would it be possible to add it?

Comments (12)

  1. agriggio repo owner

    Hi,

    I’m not sure I fully understand the request: are you suggesting to add a contrast mask to the spot removal tool? That can be considered, but I’m not sure this is what you are asking 🙂

    If not, what else? Can you be more specific and/or maybe share a raw file on which the current spot removal is ineffective? I have zero experience with digitizing film…

  2. Michael Ezra reporter

    The spot removal is a manual laborious process.

    The purpose of Dust & Scratches filter to automatically (based on user input: radius, contrast threshold, mask parameters) select the areas that need to be inpainted, and then apply the inpainting.

    Photoshop has a simple version of this filter, with two sliders - Radius & Contrast Threshold. It simply fills in the identified areas with the blur of the surrounding.

    Applying inpainting and selecting the dust & scratches region more intelligently would be a logical evolution. Applying such filter in raw processor with ability to correct the mask would be a great timesaver.

    Here is sample image with scratches and a bit of dust:

  3. Michael Ezra reporter

    Flatbed scans of prints from scratched negatives.

    Detection of dust with Focus Mask:

  4. Michael Ezra reporter
    • Sample of debree on film (scan using film scanner, so its pretty sharp)

    • debree on a negative photographed with camera (less sharp),

    • same, but in busy image area

  5. Michael Ezra reporter

    A couple of more samples - flatbed scans of BW prints.

    These provide a clear illustration, why automated intelligent Dust & Scratches filter can be a huge time saver, vs manual spot retouching:

  6. Paul Matthijsse

    Hello Michael,

    Yes that would be great, an automatic dust & spot removal tool! But I’m afraid that’s never going to happen, because no algo in the world will be able to distinguish dust and scratches from other details, like light spots or glasses with reflections or details of clothes.

    If I understand you well, you want to select an area and then filter for dust, based on the focus mask? Do you have an example of that Photoshop filter?

    (If I remember well, you were behind the focus mask thing in RT, weren’t you?).

    I do agree that for retouching scans, the ART implementation is a bit cumbersome to work with.

    Regards, Paul.

  7. Michael Ezra reporter

    Hello Paul,

    Below is the illustration of dust & scratches filter in Photoshop:

    Filter preview is enabled:

    As you can see, filter removes dust & scratches, but the real image details are being blurred as well.
    Also, the dust and scratches areas loose their texture in Photoshop implementation, so in some cases I manually add grain on top of this filter.
    Inpainting dust & scratches while retaining the texture from the surrounding area, or providing option to add grain would be a great functional improvement.

    A usual workflow in Photoshop would be:

    1. copy image into a new layer
    2. apply Dust & Scratches filter in this new layer
    3. Add mask to this layer and manually paint the mask:

      1. paint black the areas where filter should not be applied
      2. or invert the mask to black and paint with white brush areas where filter should be applied.
    4. Flatten the image, or merge layers.

    This Photoshop workflow is cumbersome for batch application.

    I agree that an entirely automatic removal of dust & scratches would require and AI engine.

    What I was thinking of here is primarily a guided semi-automatic mode.

    1. provide an ability to isolate the areas of dust and scratches:

      1. user to manualy set the detection radius, contrast threshold, and
      2. perhaps also leverage the focus mask algorithm, but use it with different constants than those used for focus detection.
      3. also, take into consideration weather dust and scratches are colored either bright (negative scans) or dark (transparency scans)
    2. inpaint isolated areas, automatically, based on the surrounding image data

    3. allow localized correction via application of additional masking. E.g. manual input via brushes.

    I did design the initial focus mask (years ago) and then also Ingo added very significant speedups and functional enhancements (a broader highlight of areas in focus and color gradation of the focus mask to reflect the degree of sharpness)

    Michael

  8. Paul Matthijsse

    Hi Michael,

    Your Photoshop example is amazing, I’ve never seen a result like that with other software including VueScan, SilverFast or G’Mic (or RT/ART)! It would be great to have a filter like that, or your semi-automatic mode, in an open source raw convertor, but as I’m not a programmer, I can’t help you here. I suppose the Photoshop filter isn’t open source?

    Regards, Paul.

  9. Michael Ezra reporter

    Perhaps it makes sense to post this feature request in RT forum. There is lots of code sharing and both branches can benefit.

  10. Paul Matthijsse

    Hello, I thought your filter was a third-party plugin. Many other filters for sharpening and denoising are based on scientific papers, so I thought your scratch filter could be one of them.

    And yes, I know PS isn’t open $$ource ! 😉

  11. Log in to comment