[magick-users] Mathematical Cloud Composition

Anthony Thyssen anthony at griffith.edu.au
Mon Jul 9 18:28:09 PDT 2007


"Ashton Peters" on  wrote...
| Hi, I have a question related to image composition and transparency. I have
| two satellite images, one is a map, and one is a cloud image.
|
| Map: http://img379.imageshack.us/img379/4205/nzdaylp9.png (700k)
|
| Clouds: http://img465.imageshack.us/img465/3254/nzcloudstc9.jpg (300k)
|
| What I would like to do is combine these images to make a realistic looking
| cloud overlay. I have read a technical report available at
|
| http://www.urania.be/weer/cloudmaps20060203.pdf
|
| that obtained great results using alpha blending as a function of cloud
| image pixel intensity. An equation is used that applies a transparency to
| each pixel of the cloud image based on the following formula:
|
| alpha = (cloudgrey^2) / (255^2)
|
| where alpha is the output pixel transparency value, and cloudgrey is the
| greyscale value of the cloud image pixel (between 0-255).
|
| Is it possible to use ImageMagick to create a transparency map as an
| arbitrary function of pixel values, then apply the transparency map to
| compose the two images? I have experimented with the built-in alpha
| compositing methods in ImageMagick and I can't seem to find one that allows
| the creation of a transparency map based on a user-defined function.
|
Certainally.  Assuming the JPG is grey scale

  convert nzcloudstc9.jpg \( +clone \) -compose multiply -composite \
          \( +clone -fill white -colorize 100% \) +swap \
          -compose CopyOpacity -composite \
          nzdaylp9.png +swap +compose  -composite \
          cloud_overlayed.png

Note replace multiply with screen for a brighter clound overlay

Alturnatives is to directly 'screen' overlay the white..
(black is unchanged, white becomes white - image order do not matter)

  convert nzcloudstc9.jpg nzdaylp9.png -compose screen -composite \
          cloud_overlay.png

OR with squaring (to darken the overlay)
  convert nzcloudstc9.jpg \( +clone \) -compose multiply -composite \
          nzdaylp9.png -compose screen -composite    cloud_overlay.png

For more compose methods see..  IM examples
   http://www.imagemagick.org/Usage/compose/

Specifically look at multiply, copyopacity and screen

If you have the lastest IM, you can also try three image 'masked' overlays.

Let us know what you decide to do.

  Anthony Thyssen ( System Programmer )    <A.Thyssen at griffith.edu.au>
 -----------------------------------------------------------------------------
  Let me tell you, you nonexistent reader, sitting there with a tolerant
  sneer :  don't be smug!       -- Robert Heinlein "Number of the Beast"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/


More information about the Magick-users mailing list