Is it possible to create kernel which will blur the parts of image which are sharp and also will sharpen the areas which are blur?
For instance in this image I have marked regions with text which should be sharpen more (red frame) and areas which should be sharpen less (orange regions). The bottom right should be blurred.
Inverse blur/sharpen kernel
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Inverse blur/sharpen kernel
Use "-compose Blur" with a mask that is white where you want to blur, and black where you don't want to blur (and gray in the middle).
For selective sharpening, do a selective blur but then extrapolate from the blur, past the input image.
For selective sharpening, do a selective blur but then extrapolate from the blur, past the input image.
snibgo's IM pages: im.snibgo.com
Re: Inverse blur/sharpen kernel
Hi,
I was looking for the solution of almost the same problem. I need to selectively sharpen some pictures (in batch modus) -- like here http://digiretus.com/selective-sharpening-in-photoshop/ in Photoshop. The top of the photograph should be sharpened and towards the bottom the factor should gradually decrease. I am able to prepare N-S gradient mask however I don't understand what snibgo means with extrapolate from the blur, past the input image.
Could someone provide a small example?
I was looking for the solution of almost the same problem. I need to selectively sharpen some pictures (in batch modus) -- like here http://digiretus.com/selective-sharpening-in-photoshop/ in Photoshop. The top of the photograph should be sharpened and towards the bottom the factor should gradually decrease. I am able to prepare N-S gradient mask however I don't understand what snibgo means with extrapolate from the blur, past the input image.
Could someone provide a small example?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Inverse blur/sharpen kernel
See https://imagemagick.org/Usage/mapping/#blur for the basic variable blur. I am not sure what snibgo meant either, but I do not think it applies to your case. The basic variable blur should do what you want. For sharpening, I think you can create the blurred version and then subtract some fraction of it from the original (sort of unsharp masking)
Alternately and more efficiently, make a sharpened copy of your image and use the gradient as a mask to blend to the two images. See https://imagemagick.org/Usage/compose/#compose for the masked composite operation.
See also https://imagemagick.org/Usage/photos/#tilt_shift
Alternately and more efficiently, make a sharpened copy of your image and use the gradient as a mask to blend to the two images. See https://imagemagick.org/Usage/compose/#compose for the masked composite operation.
See also https://imagemagick.org/Usage/photos/#tilt_shift
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Inverse blur/sharpen kernel
This is unsharp masking, but in this case with a selective (ie variable) blur, so the sharpening is also selective.snibgo wrote:... extrapolate from the blur, past the input image.
When we have an image and a blurred version of that image, the result could be an interpolation between those two versions, anywhere between the blur and the original. Or it could be an extrapolation, past the original, which increases sharpness.
See Selective blur "Toytown effect".
snibgo's IM pages: im.snibgo.com
Re: Inverse blur/sharpen kernel
Many thanks for your answers.
Do you mean something like:
w=$(convert image -format "%w" info:); h=$(convert image -format "%h" info:); convert -composite image \( +clone image -unsharp 0x3+1+0 \) \( +clone -size 1x$h gradient: -fx "atan(u*Pi)/atan(Pi)-.1" -negate -scale "$wx$h !" \) result.jpg
?
I will start to experiment with the parameters.
Do you mean something like:
w=$(convert image -format "%w" info:); h=$(convert image -format "%h" info:); convert -composite image \( +clone image -unsharp 0x3+1+0 \) \( +clone -size 1x$h gradient: -fx "atan(u*Pi)/atan(Pi)-.1" -negate -scale "$wx$h !" \) result.jpg
?
I will start to experiment with the parameters.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Inverse blur/sharpen kernel
Something like that, yes.
In the bad old days, IM commands could list the operations in any order you want, and IM would process the operations one after the other in whatever order it wanted.
These days, IM will process the operations in the same order they are given. So "-composite" before any images have been read won't do anything, because there are no images to composite.
In the bad old days, IM commands could list the operations in any order you want, and IM would process the operations one after the other in whatever order it wanted.
These days, IM will process the operations in the same order they are given. So "-composite" before any images have been read won't do anything, because there are no images to composite.
snibgo's IM pages: im.snibgo.com