Smart Sharpening in Imagemagick

So, I’ve found that the Smart Sharpening workflow described here can give really stellar results. But I’m lazy, and was interested in a way that I could adjust images without having to open them in a graphical environment, and preferably do a bunch at once. I essentially converted the steps described by gimpguru into imagemagick and ended up with something that works. I’m still testing a few different ideas, but I find it’s working reasonably well at the moment (you can judge for yourself on the basis of examples, though the flickr images will give you a better idea). But in the spirit of sharing… you can find it here.

Timings: 10 MP image, about 35 seconds
Note this will avoid name collisions presently, so if you have a 2, 4 or 8 core cpu, and you use (ls *.jpg|xargs -n 1 -P # you can get a 2, 4 or 8x speedup, or 20, 10 or 5 seconds per image. This is really not a lot of time, and trivial compared to the amount of time you could expect to spend in the gimp doing the same thing.

Apparently someone has already tried to implement this in the gimp. This would be a nice way to try a bunch of different parameters, unfortunately it does not have a preview (and that would be very hard to do), and parameters would not be a perfect match from that one to this one, as I use a different edge detection method. And I don’t believe I can use the gimp edge detect method without quite an investment. I’ll investigate though.

Some examples: These are crops from three larger images (full size available here), the images are the original, the final and the mask generated by the script used for sharpening,.


Pattern Noise Reduction

This little algorithm seems to significantly reduce pattern noise in digital images.  Instead of doing dark frame subtraction, the output value at each pixel is taken to be the average of the initial value with weight (1-dark) and the value of pixel in a gaussian blurred image with weighting of (dark).  Where dark is an element of [0,1].

I wrote this because I wanted something I could apply to webcam images both night and day that would eliminate hot pixels in night shots and would not create dark spots in day shots. Seems to work pretty well.

This is pseudo perl, and calls the imagemagick library, but you get the idea.

# pseudo-code creative commons – attribution – share alike
# author Joseph Bylund
# i.e. please copy, please give to your friends, please modify, please give me credit
use strict;
my $corrections = “pixel_corrections.png”;
my $mydark = “./dark_frames/dark_frame_avg.png”;
my $start = “webcam_pic.png”;
my $lessdark = “lessdark.png”;
my $startbydark = “startbydark.png”;
my $radius = 4;
convert -compose multiply -composite $mydark $start $startbydark
convert -evaluate Multiply 2.54 $startbydark $startbydark
convert -compose minus -composite $startbydark $start $lessdark
convert -gaussian-blur 20x$radius $lessdark $lessdark\_blur.png
convert -compose multiply -composite $mydark $lessdark\_blur.png $corrections
convert -evaluate Multiply 2.54 $corrections $corrections
convert -compose plus -composite $lessdark $corrections final.png”);