Page 1 of 1

Suggestions: gradually-revealing image

Posted: 2011-03-07T05:38:23-07:00
by Docproc
Hi all

I'm relatively new to IM, and now have a job which I'm sure it can do, I'm just in need of some pointers as to the best way to go about it.

I have an image, which is the logo of the project I'm working on. I want to turn this into a series of images that can represent the progress of certain tasks. So I want 0% progress to be the image in grayscale, 25% progress to be the left-hand 25% of the image in colour, the rest greyscale, 50% being the left-hand half of the image in colour, and so on until the whole image is in colour representing 100%.

I plan to write a Perl script to automate this (I assume it'll be a series of IM convert commands), but I need to figure out how do it in principle first.

I assume I need to generate a series of masks of increasing width, and composite them with the original image, using an appropriate compositing method.

Am I on the right track here? Any tips will be gratefully appreciated.

Thanks in advance

Glenn.


IM 6.3.7 on Mac OS X 10.6.6

Re: Suggestions: gradually-revealing image

Posted: 2011-03-07T10:10:14-07:00
by HugoRune
check out http://www.imagemagick.org/Usage/channels/#zeroing
http://www.imagemagick.org/Usage/channe ... bine_other
http://www.imagemagick.org/Usage/compose/#multiply

basically you need to select the saturation channel with
-colorspace HSL -channel G
then multiply the channel with a gradient mask
-compose Multiply

where the mask is black, the resulting image will be grayscale, and where it is white, it will be left unchanged

Re: Suggestions: gradually-revealing image

Posted: 2011-03-07T10:14:38-07:00
by fmw42
one way is to just crop the image by percent, create the appropriate transparent percent image and the appropriate grayscale percent image and append together horizontally. Just compute the image size and use your percent to get the crop amount and the sizes of the transparent and grayscale images.

Another way is to use binary masks thresholded from a horizontal gradient and multiple composites to create the 3 sections.

This does the left side and the rest transparent.

thresh=25
ww=`convert rose: -ping -format "%w" info:`
hh=`convert rose: -ping -format "%h" info:`
convert rose: \( -size ${hh}x${ww} gradient: -rotate 90 -threshold ${thresh}% -negate -write mpr:mask \) \
-alpha off -compose copy_opacity -composite rose_t25.png


You need to composite a grascale image over the right side.

Re: Suggestions: gradually-revealing image

Posted: 2011-03-07T20:25:16-07:00
by anthony
Does the logo contain transparency?

Without transparency you can simplify the process, especially if you don't want a sharp change between the left (color) and the right (greyscale) sides during the 'wipe'.

However as the same background transparency will be used between the first and final images, and thus all the images between, then you can make use of that simplification.

STEPS...
  • extract the transparency channel form the image (save it for later)
  • Generate a de-saturated version of the image (starting point)
  • create a animation sequence wiping from grey to color
    You can use Fred Weinhaus's 'transitions' script for that
    Or generate a sequence of transition masks, which you apply to the color image (which as the image has no transparency at this point makes it easier), and then overlay that transition sequence on top of the starting grey image.
  • Re-add the transparency mask to complete the animation
NOTE: you should NOT continually re-save the intermedite animation sequences as GIF as GIF is a lossy file format. Either do all the work in memory, or save as a multi-image MIFF file. Only the final animation should be saved as GIF.

Re: Suggestions: gradually-revealing image

Posted: 2011-03-08T00:53:01-07:00
by Docproc
Thanks for the helpful suggestions folks, I've succeeded in getting what I want. In the end I did the following:

- made a grayscale copy of the original image to serve as the "background"

- used -crop on the original image with increasing percentage widths to create coloured vertical slices

- composited each slice in turn with the gray background to produce the final images

I'm very happy with the result, I wouldn't have been able to do it without your help. Thanks a lot!

Glenn.