Remove scratches with Despeckle

Hello,
I’m trying to remove scratches from old scanned BW photos. I did some test with GMIC-QT DigiKam plugin. The result is excellent in the preview, but after ‘Apply’ and/or OK, returning in Digikam the resulting image is the same of original (no corrections are made).
Usinf another filter It works.
I made a test from the gmic command line :
gmic -input img2672.jpg -gcd_despeckle 20,10 -output out.jpg
but the result is the same: the out.jpg looks equal to the original
I’m doing something wrong ?
Somebody cam help me ?
Thanks in advance.

Pinging @garagecoder since he made the gcd_despeckle code.

1 Like

Ciao!

Could you please share an “Input”-file,
so that we could test with our own fingers?

Sure.
It’s not the same image but the result is the same.
The command is: gmic -input img2377.jpg -gcd_despeckle 20,10 -output out.jpg
Gmic version 3.1.0; Linux Mint 20.3
Same result with digiKam+gmic-qt (version 2.9.3)
Here the screenshot

img2377.jpg

out.jpg

@Ric_Developer afre_cleanphoto and afre_cleanphoto1 may be useful to you. Read afre's G'MIC diary - #160 by afre for more information. They were made to address one person’s needs, so may not be for general use, but with feedback from you, I could make some improvements.

1 Like

Sadly I can’t look at this until the weekend, but my guess is a problem related to preview scale vs actual. If there’s no good reply by somebody else, I’ll see what can be done (when I can)!

@garagecoder
Don’t worry
Thx!

Having reviewed the code, I’m convinced the output difference is due to the preview being scaled down vs the original. The problem is what to do about it…

I’ve considered updating the filter to be based on percentage of image dimensions, but that could break things for other people using it (it’s a very old filter). Breaking backward compatibility is a last resort for me!

So how about a new or alternative filter? Well, looking at your examples I think there’s much more to it than at first glance - there are probably two reasons it fails on the full scale image; the image flaws are more difficult to cleanly mask as detail increases, plus the inpaint algorithm is one of the most basic available and probably won’t look good either.

We have quite a long history of attempts to solve this sort of problem, some of which can be seen in https://discuss.pixls.us/t/scanned-image-scratch-removal-with-ice/2350

This probably sounds like avoiding work (maybe some truth :slight_smile: ), but my only advice can be to try a different approach or filter - there are lots, because it’s a hard problem. Creating a good mask of the flaws is the difficult part in your example.

1 Like

You have full-size preview support for G’MIC now. Also, percentage-based output is what should be done from beginning.

Yes, today I generally do everything I can to make filters scale invariant. I think backward compatibility is more important in this case - it’s such an old filter it may be used in scripts by people.

I don’t think so. In these forums I see several people of good will who share their work and experiences. Thanks for your suggestions. I will try. I agree with you about backward compatibility; I’ve a lot of experience on It.
@afre I will try your filters also (It’s a busy weekend!)

1 Like

@afre I could not resist, I did some tests. afre_cleanphoto is the best for me although by changing the parameters I got the same result (a very good result). With afre_cleanphoto1 I don’t get good results.

I don’t quite understand this part of the sentence

but it sounds like you were pleased by the result.

That is good to know and why feedback is great.

@afre I don’t know If Is my bad English (I’m Italian) or the confusion in my mind ( :stuck_out_tongue_winking_eye:); sorry.
I made the first test with afre_cleanphoto 6,10,-30 → very good result
next afre_cleanphoto 6,10,-30 → nothing has changed, same result as first test
next afre_cleanphoto 4,10,-30 → as before
Trying with different parameters I wanted to understand the behavior.

1 Like