Is it possible to modify (blur)a polyline-area of a picture?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is it possible to modify (blur)a polyline-area of a picture?

Post by fmw42 »

You can blur the whole picture. Then draw the polyline on the original. Then make a binary mask from the polyline area. Then use -composite to overlay the one with the other using the mask to control which area shows from the original and which area shows from the blurred image.

see:
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/compose/#mask
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Is it possible to modify (blur)a polyline-area of a picture?

Post by anthony »

As mentioned by fmw42, create a blured picture. But also generate a plotline mask to select between the original picture and the blurred picture.

Code: Select all

convert original.jpg \( +clone -blur 0x5 \) \( -size 640x480 xc:black -fill white -draw 'polyline 255,390 220,420 290,420' \) -composite blurred_window.jpg
You may however like to blur (feather) the mask slightly to make it a more gradual change.

Code: Select all

convert original.jpg \( +clone -blur 0x5 \) \( -size 640x480 xc:black -fill white -draw 'polyline 255,390 220,420 290,420'  -blur 0x2 \) -composite blurred_window2.jpg
At the moment however there is no method to adjust the blur amount according to some mask. Such a method would be useful for generating shadows that get more blurry the further they extend from some object.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply