In Action
afre_cleanphoto graduated from the misc section.
ATM, it is only available in CLI. Remember to gmic update
. (I will leave the rush commands afre_cleanphoto0
and afre_cleanphoto1
in afre.gmic
for now, even though this replaces them.)
afre_cleanphoto:
2<=size<=10,1<=_recovery<=100,-50<=_xy_sections<=50,_mask1>=1,_mask2>=1,...
Clean dust and scratches from photos.
Default values: 'size=3', 'recovery=10', 'xy_sections=1' and 'mask1=1'.
'xy_sections' has special properties.
- 'xy_sections>0': process masked regions specified by 'mask1','mask2',...
- 'xy_sections<0': assign and display numbered regions.
In this segment, I will show you what it does. There is nothing special about afre_cleanphoto
per se; it is a matter of thinking through the problem. Take the following image, which has dust fragments that we want to remove or reduce:
Since the fill algorithm is simple and unintelligent, we don’t want it to alter more of the image than is necessary, so the plan is to separate the image into regions, the simplest of which is a grid that would be small enough to grab areas of similar features. Roughly for this image, that would be a 30x30 mapping.
afre_section
helps us with this and is built into afre_cleanphoto
. You invoke it by giving the third parameter ‘xy_section’ a negative number; in our case, I have chosen -30 to subdivide the image into 900 subregions. Again, this is a minimalist method but that is our objective. It may introduce tiling artifacts and I have applied weights to mitigate that somewhat.
gmic 502.jpeg afre_cleanphoto 6,10,-30 output 502-section.png
If xy_section=1
, then the command will filter the entire image as one big section. Besides unnecessarily altering unblemished areas, this kind of processing is rather slow. Therefore, I would rather take a hit in introducing tiling artifacts that weights won’t ameliorate completely.
Now, we are tasked with choosing which areas to modify. I have selected about 80% of the blemishes.
gmic 502.jpeg afre_cleanphoto 6,10,30,152,182,725,755,296,297,784,814,816,845,846,871,775,798,330,360,536,224,220,655,715,240,270,852,706,818,453 output 502-cleanphoto.png
Now for the result. You may zoom and toggle among the images in this post to see the difference. Better than before!
Note that it would have probably been easier on the command if we had considered doing some pre-processing. This input image has lots of things needing correction: lens distortion, vignetting, chromatic aberration, scanning artifacts, nonlinear gamma, file type and compression artifacts, among others. There is only so much a single command can do in light of these.