How can I get smart sharpen effect on my images using python?

I am wondering how to smartly sharpen an image using python or any related image library like ndimage , skimage or even PIL . I can find methods that actually sharpen mine but with a lot of noise and pixelation when scaling. Since I know Photoshop , I tried to get this clever sharpness effect, which sharpen the image with less noise and a nice sweet contrast through python, but I failed.

Notes: -
(1) have been verified: -

 >>> # The 1st Method: >>> import Image >>> import ImageFilter >>> image.filter(ImageFilter.SHARPEN) >>> Image.filter(ImageFilter.EDGE_ENHANCE_MORE) #Look down:1st image created >>> # The 2nd Method: >>> blurred_l=scipy.ndimage.gaussian_filter(b,3) >>> filter_blurred_l = scipy.ndimage.gaussian_filter(blurred_l, 1) >>> alpha =30 >>> sharpened = blurred_l + alpha * (blurred_l - filter_blurred_l) >>> # The 3rd Method: >>> shar=imfilter(Image,'sharpen') #Look down:2nd image created 

(2) I found a piece of code, but in Perl . I only know python here or directly (3) Here are 2 pointed images using the above methods, the third using smartsharp:
Original
Original image http://imageshack.us/a/img600/6640/babyil.jpg
First................................................. ................... second
1st http://imageshack.us/a/img803/3897/sharp1.png 2nd http://imageshack.us/a/img809/2235/sharp2.png
my third goal> is that the effect I want is 3rd http://imageshack.us/a/img832/4563/smartsharp.jpg
(4) Here is the tool I used to create the third image above:
smrsharpm http://imageshack.us/a/img210/2747/smartsharpentoolm.jpg smrsharp http://imageshack.us/a/img193/490/smartsharpentool.jpg p>

+4
source share
2 answers

Unfortunately, it's hard to understand what โ€œSmart sharpenโ€ does without access to Photoshop code. In the meantime, you can try mixing the unsharpen mask, completely filtering the variations and some color adjustment (maybe the hue will increase a bit).

Also see: http://www.kenrockwell.com/tech/photoshop/sharpening.htm#

Update: here is an example of how to remove image blur from an image:

https://github.com/stefanv/scikit-image-demos/blob/master/clock_deblur.py

(the image of the clock is in the same repository). Unfortunately, scikit-image does not currently have mature attenuation / inversion filtering - but we are working on it!

+4
source

Photoshop's smart sharpening feature uses a mathematical operation called deconvolution inside. numpy has a deconvolve() function, which can probably be pressed to serve this task, but I could not find a ready-made function for smart sharpening using numpy , so you probably have to code it yourself.

An alternative approach would be to do this using GIMP. There's a GIMP plugin (intuitively named "G'Mic") that will perform deconvolution among other sharpening algorithms, and you can automate GIMP using Python.

+4
source

Source: https://habr.com/ru/post/1441405/


All Articles