using Radial Flare for a mask

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
grepper
Posts: 7
Joined: 2010-04-14T06:37:54-07:00
Authentication code: 8675308

using Radial Flare for a mask

Post by grepper »

Hi all, first post ...
While reading http://www.imagemagick.org/Usage/advanced/#stars , it occurred to me that the first example radial flare would make an excellent mask for a thumb shape (flare_1_final.png). I wasn't sure if it was the right combination of color for a mask, but it appears to work fine using the composite formula given in the examples pages for using a mask: composite -compose CopyOpacity flare_1_final.png +matte \( rose: -resize 100x100! \) out.png. This is fine, but since the mask goes right to the edges it will show an implicit border when using a different color background. How could that radial flare command be modified so that the edges are fully transparent ?

thanks,

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

Re: using Radial Flare for a mask

Post by fmw42 »

if I understand, then simply pad your flare image (mask) with black to be the same size as the image you want to overlay it on. Then when it becomes the alpha channel, the black will become transparent.

see -background black -extent WidthxHeight

http://www.imagemagick.org/Usage/crop/#extent
grepper
Posts: 7
Joined: 2010-04-14T06:37:54-07:00
Authentication code: 8675308

Re: using Radial Flare for a mask

Post by grepper »

Thanks for your reply. In this case I don't see how that would work. Here is the command from the Usage page:

Code: Select all

convert -size 100x1 xc: +noise Random -channel G -separate +channel \
-scale 100x100\! \( -size 100x100 gradient: -sigmoidal-contrast 8x50% \) \
-compose hardlight -composite -virtual-pixel HorizontalTileEdge \
-distort Polar -1 flare_1_final.png
If you try this command, then use flare_1_final.png as a mask, you will see that because random pixels will get no further than the current edge, it creates an implicit border which will show even when using a transparent background. Because I really don't understand the complexities of this command, I don't see where or even if it is possible to set a larger canvas for the flare to do what I would like.

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

Re: using Radial Flare for a mask

Post by fmw42 »

I guess I do not understand what it is that you need to do. Can you show an example of your problem?


try this:


convert \( rose: -resize 100x100! \) flare_1_final.png \
\( -clone 1 -threshold -1 -virtual-pixel black -blur 10x65000 -level 50x100% \) \
\( -clone 1 -clone 2 -compose multiply -composite \) \
-delete 1,2 -compose copy_opacity -composite out2.png
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: using Radial Flare for a mask

Post by Bonzo »

Some interesting results!
Image
Image
Image

Something not quite right though!

I assume you want a "lens flare effect" similar to the second image but retaining the colour?
grepper
Posts: 7
Joined: 2010-04-14T06:37:54-07:00
Authentication code: 8675308

Re: using Radial Flare for a mask

Post by grepper »

Thanks for your reply. I wanted something like the example I gave using rose: in my 1st post.

Code: Select all

composite -compose CopyOpacity flare_1_final.png +matte \( rose: -resize 100x100! \) out.png
Image
So that the image takes the shape of the flare. But what I would like is that the rays of the flare, of varying lengths, NEVER REACH THE EDGE OF THE MASK, and the edges are fully transparent. So that the result is an image that you could seamlessly overlay on any background and you would not see that it is in fact rectangular. You can clearly see that the rose image above is in fact rectangular (100x100) because of the edges. So it is the mask itself which needs adjusting.

Wow I'm having a hard time explaining myself ...

Robert
Last edited by grepper on 2010-04-15T06:26:58-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: using Radial Flare for a mask

Post by fmw42 »

something like this:

Image

If so, then I will have to make some mods to my starbrust script to overlay the starburst into the alpha channel rather than simply compositing.
see link below


P.S. Bonzo,

how did you make your blue starburst with transparent background.
grepper
Posts: 7
Joined: 2010-04-14T06:37:54-07:00
Authentication code: 8675308

Re: using Radial Flare for a mask

Post by grepper »

Thanks, that is what I wanted. Unless I am missing something, it appears to work fine with the image produced by your starburst script without modification. Though there appears to be a lot of empty space around the image that a -trim +repage doesn't affect, so perhaps that is what you meant.

Code: Select all

starburst -s 100x100 -n 100 a.png

composite -compose CopyOpacity a.png +matte \( rose: -resize 100x100! \) b.png
Image

Robert
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: using Radial Flare for a mask

Post by Bonzo »

I would like to say I created some realy clever and complicated code Fred but it was by accident !

Code: Select all

exec("convert -size 100x1 xc: +noise Random -channel G -separate +channel -scale 100x100! ( -size 100x100 gradient: -sigmoidal-contrast 8x50% ) -compose hardlight -composite -virtual-pixel HorizontalTileEdge -distort Polar -1 -background black -extent 300x156 flare_3_final.png");

exec("convert ( Blue_sunset.jpg -resize 300x300 ) flare_3_final.png ( -clone 1 -threshold -1 -virtual-pixel black -blur 10x65000 -level 50x100% ) ( -clone 1 -clone 2 -compose multiply -composite ) -delete 1,2 -compose copy_opacity -composite -trim out5.png");
I think the final image is quite good due to the strong colours in the original image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: using Radial Flare for a mask

Post by fmw42 »

grepper wrote:Thanks, that is what I wanted. Unless I am missing something, it appears to work fine with the image produced by your starburst script without modification. Though there appears to be a lot of empty space around the image that a -trim +repage doesn't affect, so perhaps that is what you meant.

Robert
Robert,

you can control the length of the flares with the -r option


Fred
grepper
Posts: 7
Joined: 2010-04-14T06:37:54-07:00
Authentication code: 8675308

Re: using Radial Flare for a mask

Post by grepper »

Awesome, thanks Fred. I will be using the code you provided in your script in a script that makes DVD's from provided files: todisc from the tovid suite. http://tovid.wikia.com (with attribution to you and Anthony Thyssen of course). It will be one of the -thumb-shape options and looks really good in an animated menu! Applying a fair amount of blur also gives a nice semi-transparent vignette like effect.
Thanks too to Bonzo for his comments and code example.

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

Re: using Radial Flare for a mask

Post by fmw42 »

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: using Radial Flare for a mask

Post by anthony »

Radial Flares are fun... But what i would really like to to make them more 'ray' like.

That is thick at the center and thinning out to nothing at the edges. At the moment the technique makes rays radially wider toward the edges.

my best results so for have been regular rays... as in Stars and Comets
http://www.imagemagick.org/Usage/advanced/#stars

However generating randomise rays, has not had a satisfactory answer as yet.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply