Soft Edges

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
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Soft Edges

Post by xpt »

Hi,

The online help doesn't give me much info about the vignette usage,
http://www.imagemagick.org/script/comma ... ?#vignette
-vignette radius{xsigma}{+-}x{+-}y{%}

soften the edges of the image in vignette style.
Is the radius measured from the edge or the center?

My ultimate goal is to blur the part outside the 75% from the center, Ie, the soft blurry outline takes up to 25% of image size. How can I do that?

Thanks
Last edited by xpt on 2010-10-11T14:00:45-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: vignette usage

Post by fmw42 »

see http://www.imagemagick.org/Usage/transform/#vignette and http://www.imagemagick.org/Usage/thumbnails/#soft_edges for a little more info and examples.

The radiusxsigma is set for a gaussian blurring (to get soft edges). If you want a gaussian vignette, set 0xsigma where sigma is approx desired radius / 3. Or if you want a linear vignette use radiusx65000.

x, y: Define the x and y ellipse offset.

I suggest some trial an error testing.

Please report back here what you find.
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: vignette usage

Post by xpt »

Yes, that's where I found out the vignette usage.

The problem is that all above example gives a slim soft edges, whereas I want a much thicker one (25%). And I still don't know which factor should I tweak to get that.

Please help.
thanks
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: vignette usage

Post by xpt »

fmw42 wrote:If you want a gaussian vignette, set 0xsigma where sigma is approx desired radius / 3.
Please forgive my ignorance, we are talking different languages here. Please tell me how to translate about into my 25%.

Thanks
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: Soft Edges

Post by xpt »

xpt wrote: My ultimate goal is to blur the part outside the 75% from the center, Ie, the soft blurry outline takes up to 25% of image size. How can I do that?
Ok, maybe vignette might not be the perfect tool for it, so I changed the subject.

I'm playing with the Virtual Pixels....
You can also blur transparent Virtual Pixels to add a slightly more rounded softer feathering to the image, especially around the corners.

convert thumbnail.gif -alpha set -virtual-pixel transparent \
-channel A -blur 0x8 -level 50%,100% +channel soft_edge.png
Through trial an error testing, I've come to the conclusion that '-blur 0x120' is good for my 440x293 test image.

How should I interpret this 0x120 vs. my 440x293 image dimension?
How can I apply the similar scale to my next image?

Thanks


Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Soft Edges

Post by fmw42 »

0x120 is a gaussian blur with sigma=120 pixels

your image is about 400x300 pixels so take the ratio of 120/300=0.4 or 40%. So take your next image size and take 40% of it and use that for the sigma
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: Soft Edges

Post by xpt »

Thanks, thanks, thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Soft Edges

Post by fmw42 »

Here are some vignette tests. The radiusxsigma does not seem to be image size dependent. That is the basic size of the vignette covers the same proportion of the image for the same radiusxsigma. You use the +x+y to make it bigger or smaller. The radiusxsigma sets the blur amount.

original small image
Image

convert young_girl2.jpg -background black -vignette 0x25 young_gril2_0x25.jpg
Image

convert young_girl2.jpg -background black -vignette 0x15 young_girl2_0x15.jpg
Image

convert young_girl2.jpg -background black -vignette 0x15+10+10% young_girl2_0x15+10+10.jpg
Image

Double size original with 0x15 vignette:

convert young_girl.jpg -background black -vignette 0x15 young_girl_0x15.jpg
Image
Last edited by fmw42 on 2010-10-11T19:22:54-07:00, edited 2 times in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Soft Edges

Post by anthony »

If you are wanting a more rectangular vignette and don't like the heavy blurring provided by
using -blur with such a large sigma. The alternative is to use the new morphology distance function
to generate a transparency blur.
See Distance Feathering
http://www.imagemagick.org/Usage/morpho ... ce_feather

See Thumbnails, Soft Edges
http://www.imagemagick.org/Usage/thumbnails/#soft_edges

I am sorry the examples are still so raw and no entry has been added to the 'Vignette Transform' areas of IM examples.

The result will be a perfect 'linear' distance gradient form the edge but that can be adjusted using some gradient modification operators like -sigmoidal-contrast.

Also while the distance gradient function is currently a repeated iteration technique 9It should be faster that using Blur. Eventually it should also allow for a FAST two pass method distance technique. Which is on my ToDo list.

I am sure Fred will play with this to give you a proper example.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
xpt
Posts: 59
Joined: 2010-10-06T20:18:24-07:00
Authentication code: 8675308

Re: Soft Edges

Post by xpt »

anthony wrote:If you are wanting a more rectangular vignette and don't like the heavy blurring provided by
using -blur with such a large sigma. The alternative is to use the new morphology distance function
to generate a transparency blur.
Yes, I know that. Just that my imagemagick is still at v6.6.0.4 from Debian, so I went with what I can do currently.

Question,

Code: Select all

convert thumbnail.gif -alpha set -virtual-pixel transparent -channel A \
          -morphology Distance:-1 Euclidean:1,10\! feathered.png
How can I interpret "The maximum distance of the transparent area is controled by the special 10\!' distance scaling flag" into my 25%?

Thanks
Post Reply