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?".

using Radial Flare for a mask

Postby grepper » 2010-04-14T06:59:06+00:00

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
grepper
 
Posts: 7
Joined: 2010-04-14T06:37:54+00:00

Re: using Radial Flare for a mask

Postby fmw42 » 2010-04-14T09:56:09+00:00

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
User avatar
fmw42
 
Posts: 15004
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: using Radial Flare for a mask

Postby grepper » 2010-04-14T11:28:24+00:00

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
grepper
 
Posts: 7
Joined: 2010-04-14T06:37:54+00:00

Re: using Radial Flare for a mask

Postby fmw42 » 2010-04-14T11:56:55+00:00

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
User avatar
fmw42
 
Posts: 15004
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: using Radial Flare for a mask

Postby Bonzo » 2010-04-14T13:37:02+00:00

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?
Bonzo
 
Posts: 2223
Joined: 2006-05-20T08:08:19+00:00
Location: Cambridge, England

Re: using Radial Flare for a mask

Postby grepper » 2010-04-14T20:34:12+00:00

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.

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

Robert
Last edited by grepper on 2010-04-15T06:26:58+00:00, edited 1 time in total.
grepper
 
Posts: 7
Joined: 2010-04-14T06:37:54+00:00

Re: using Radial Flare for a mask

Postby fmw42 » 2010-04-14T21:37:01+00:00

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.
User avatar
fmw42
 
Posts: 15004
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: using Radial Flare for a mask

Postby grepper » 2010-04-15T06:39:57+00:00

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
grepper
 
Posts: 7
Joined: 2010-04-14T06:37:54+00:00

Re: using Radial Flare for a mask

Postby Bonzo » 2010-04-15T08:54:21+00:00

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.
Bonzo
 
Posts: 2223
Joined: 2006-05-20T08:08:19+00:00
Location: Cambridge, England

Re: using Radial Flare for a mask

Postby fmw42 » 2010-04-15T10:09:39+00:00

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
User avatar
fmw42
 
Posts: 15004
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: using Radial Flare for a mask

Postby grepper » 2010-04-15T19:06:12+00:00

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
grepper
 
Posts: 7
Joined: 2010-04-14T06:37:54+00:00

Re: using Radial Flare for a mask

Postby fmw42 » 2010-04-15T19:16:37+00:00

User avatar
fmw42
 
Posts: 15004
Joined: 2007-07-02T17:14:51+00:00
Location: Sunnyvale, California, USA

Re: using Radial Flare for a mask

Postby anthony » 2010-04-15T19:53:25+00:00

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
http://www.imagemagick.org/Usage/
User avatar
anthony
 
Posts: 8732
Joined: 2004-05-31T19:27:03+00:00
Location: Brisbane, Australia


Return to Users

Who is online

Users browsing this forum: Google Adsense [Bot], Yahoo [Bot] and 23 guests