1 year ago
#367525
Martin
Replicate smart sharpen in matlab
I'm trying to replicate photoshop smart sharpen filter in matlab. The filter has three modes: "gauss","lens" and "motion". I'm interested in "gauss" and "lens". My assumption is, the filter uses an "enhanced" unsharp masking algorithm for "gauss" and "lens". According to documentation (https://helpx.adobe.com/photoshop/using/adjusting-image-sharpness-blur.html) a form of edge detection is involved for the "lens" algorithm.
I've created a test image taken from here (https://blog.minhazav.dev/lowpass-highpass-band-reject-and-band-pass-filter/) and applied the filter in photoshop and compare it to my own unsharp mask highpass filter. You can see the test pattern below.
I contains the original image normalized to [0,1]. My highpass filtered image is generated like so:
sigma = 10;
g = fspecial("gaussian",2*ceil(3*sigma)+1,sigma);
LP = imfilter(I, g, "replicate");
HP_TEST = I-LP;
SS contains the smart sharpened image created in photoshop (amount=100, radius=10). If the ps algorithm was a standard unsharp mask, the highpass part of the image should be retrievable by:
HP_GT = SS-I;
In the plot below I'm comparing ps smartSharpen in "gauss" mode with a highpass filtered version of the test pattern.
plot(HP_GT(ceil(h/2),1:end),"k");
plot(HP_TEST(ceil(h/2),1:end),"b");
In theory I expected the results to be the same but they are not. PS seems to do some additional processing: the peaks seem to be "inverted" at some point. Does anyone have an idea what might be going on?
matlab
image-processing
reverse-engineering
photoshop
0 Answers
Your Answer