Hello,
Newbie IM user seeks simplified way to apply an effect filter to an image through a mask. For example I would like to apply gaussian blur selectively to an image using another grayscale image (which is a gradient) as the mask.
So far, I've tried to blur the image, then merged it on top of the unblurred version, using the mask image to block opacity. The result that I get is just OK, but not quite what I"m looking for. As you can see from the IM result (second image below), too much of the underlying sharp image comes through, and it has the effect of an "outer glow" in the transition area, rather than the smooth transition from sharp to blurry.
Below is the desired result that I'm trying to achieve (I made this in PS by using equivalent amount of blur and applying to the image through a selection:
Here is what I tried so far in IM:
convert sharp.jpg blurred.jpg blurmask.jpg -composite result.jpg
And I got this:
These are the images used in the above IM command:
sharp.jpg
blurred.jpg
blurmask.jpg
I did find a link to this script when researching this:
http://www.fmwconcepts.com/imagemagick/ ... /index.php
This script may provide a solution, but was wondering if anyone could think of an even simpler solution using the available operators in IM. Any suggestions very much appreciated.
Thanks,
K
Apply filter through mask?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Apply filter through mask?
you just need to control the gradient black and white ends better. try this
convert sharp3.jpg blurred3.jpg \( blurmask3.jpg -level -20,75% \) \
> -compose over -composite test3.jpg
see http://www.imagemagick.org/Usage/color/#level
convert sharp3.jpg blurred3.jpg \( blurmask3.jpg -level -20,75% \) \
> -compose over -composite test3.jpg
see http://www.imagemagick.org/Usage/color/#level
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Apply filter through mask?
It is a shame that IM does not have the direct ability to blur based on a mask, -- at least not yet!
Fred's method is to merge multiple copys of the image that has been blured by different amounts, according to the mask. It works reasonably well.
Another way that was developed is to compress the image using a distortion, then uncompress it again. The parts that has little distortion does not get blurred, while parts that get heavy distortion blurs more.
See Improved 3D Shadow, with Variable Blur
http://www.imagemagick.org/Usage/distorts/#shadow3d_var
Fred's method is to merge multiple copys of the image that has been blured by different amounts, according to the mask. It works reasonably well.
Another way that was developed is to compress the image using a distortion, then uncompress it again. The parts that has little distortion does not get blurred, while parts that get heavy distortion blurs more.
See Improved 3D Shadow, with Variable Blur
http://www.imagemagick.org/Usage/distorts/#shadow3d_var
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/