Page 1 of 1

glamourizing a photo

Posted: 2009-06-19T15:34:01-07:00
by stinky-tofu
I'd like to glamorize a photo using image magick commandline tools. The following algorithm is what I use in GIMP:
1. Make a duplicate layer.
2. Change the duplicate layer to Overlay mode.
3. Apply gaussian blur to the duplicate layer
4. Increase brightness of both layers by 15%
5. Flatten the image
6. Write it out

I tried doing this as follows (skipping step 4 for now):
convert -gaussian-blur 15 original.tif blurred.tif
convert original.tif blurred.tif -compose overlay glamour.tif

The problem is that glamour.tif has two images in it. I tried using -flatten but it doesn't work either.

Thanks in advance for any help.

--Michael

Re: glamourizing a photo

Posted: 2009-06-19T15:42:48-07:00
by fmw42
without seeing the image you are working on it is hard to know exactly. But for starters you forgot to add -composite.

For compositing see: http://www.imagemagick.org/Usage/compose/

You also need to put something in the alpha channel. So see
http://www.imagemagick.org/Usage/basics/#alpha
http://www.imagemagick.org/Usage/channels/

If you post your original and what you get from GIMP, myself or someone on this list should be able to help more.

Re: glamourizing a photo

Posted: 2009-06-19T16:05:56-07:00
by stinky-tofu
I didn't see a way to post an image on this forum, so I put them on pbase:
Original:

http://i.pbase.com/o6/34/560434/1/11400 ... iginal.jpg

Desired:

http://i.pbase.com/o6/34/560434/1/11400 ... efinal.jpg


Thanks!

--Michael

Re: glamourizing a photo

Posted: 2009-06-19T16:39:43-07:00
by fmw42
You are correct, you have to host the image elsewhere and link it in.

From your images, I don't see why you need to use an overlay. I can get very close with just the following:

convert glam_original.jpg -blur 0x0.6 -set option:modulate:colorspace HSB -modulate 115 glam_orig_b0p6_m115.jpg

Image

I used -blur rather than -gaussian-blur as it is faster. It is a separable gaussian blur. The blur sigma was 0.6 pixels and amounts to an equivalent radius of about 1.8 pixels

I used -modulate in the HSB colorspace to increase the brightess. (It also allows you to change the saturation and hue, if you want).

See
http://www.imagemagick.org/script/comma ... s.php#blur
http://www.imagemagick.org/Usage/color/#color_mods

You need a very recent version of IM (6.5.3-7) to use the -set option to use HSB as the current -modulate uses HSL and will cause increased white along with increased brightness. However at some previous time (before 6.4.0-10) it was using HSB. Otherwise, Anthony has shown how to achieve the same HSB or HSL effect without the use of -set.

Re: glamourizing a photo

Posted: 2009-06-21T20:55:27-07:00
by stinky-tofu
Although I agree that your suggestion is very quick, it doesn't give as pleasing a result. The colors are too dull.

Using your suggestion to include -composite in the command, I was able to come up with something that works pretty well. Here it is as Tcl code

set blur 15
set gamma 1.2
set sigma [expr $blur/3.0]

set tmpRoot /tmp/glam-[pid]

exec convert -blur ${blur}x${sigma} -gamma $gamma $input $tmpRoot.1
exec convert -gamma $gamma $input $tmpRoot.2
exec convert $tmpRoot.1 $tmpRoot.2 \
-compose overlay -composite [file rootname $input]-Glam.tif
file delete -force $tmpRoot-1.tif $tmpRoot-2.tif

Just to review. Th e original looked like this:
Image
The GIMP-processed image was like this:
Image
Your suggestion looks like this:
Image
My new sequence gives this:
Image

Overall, I still like the GIMP result best, but the model likes the last image best. For me it is a little too contrasty.

Thanks for your help!

--Michael

Re: glamourizing a photo

Posted: 2009-06-21T21:46:08-07:00
by anthony
stinky-tofu wrote:I'd like to glamorize a photo using image magick commandline tools. The following algorithm is what I use in GIMP:
1. Make a duplicate layer.

Code: Select all

   convert image  \( +clone \
2. Change the duplicate layer to Overlay mode.
later
3. Apply gaussian blur to the duplicate layer

Code: Select all

         -blur 5 \) \
4. Increase brightness of both layers by 15%

Code: Select all

          -modulate 115 \
5. Flatten the image

Code: Select all

  -compose overlay  -composite  \
6. Write it out

Code: Select all

              result
It total that becomes...

Code: Select all

  convert image  \( +clone   -blur 5 \)  -modulate 115 \
            -compose overlay  -composite   result
Though I tried it out and it did not seem to work very well, at least for the images I tried it with.
Do you have a reference for the technique? Or an appropriate source image which it is ment to be applied to? It sounds like a good technique to list in Im examples Photo Cookbook
http://www.imagemagick.org/Usage/photos/#cookbook

I did not use flatten as only two images were involved, and flatten generates a thrid image using the background color! It is not needed in this case.
The problem is that glamour.tif has two images in it.
So you want the images to remain separate or merge them together before hand?

This variation keeps them separate, using some image list handling and the -layers compose to merge the two separate list of images. The two list are marked by the special 'null:' image
see http://www.imagemagick.org/Usage/anim_mod/#composite

Code: Select all

  convert image  null: \( -clone 0--2   -blur 5 \)  -modulate 115 \
            -compose overlay  -layers composite   result