Thanks a lot Anthony;

I am sorry I didn't make myself clear :-(

I do not want to make a cinematic morph using RMagick,
i am familiar with that effect and it is not my purpose.

I do want to make a "color morphing transform" between two images;
that is more like a blend or a dissolve from smallimage.jpg to bigimage.jpg and i want to do it in 8 frames having as a final file a .gif ; so that is why I am using the code below
and 'morph' as the basis for it.

I am running centos 4.5 and ruby 1.8.6 and all current imagemagic and RMagick libs...


Message: 1
Date: Sun, 2 Sep 2007 22:17:50 -0500
From: Victor Rosillo <[EMAIL PROTECTED]>
Subject: [magick-users] Morph two images of different size

I need to morph two given images of different size:

smallimage.jpg (640x480 pixels at 72dpi) (no alpha channel)
bigimage.jpg (1024x768pixels at 72dpi) (no alpha channel)

I need to start the morph with smallimage.jpg
on top and at the center of bigimage.jpg
the morph has to happen in 8 frames, at the end, in frame 8,
bigimage.jpg will be seen and smallimage.jpg will have disappeared.

I'm near from getting the correct effect, but still not quite there yet,
I get a black border on the four sides of the smallimage.jpg
instead of a transparent border; so that the background image that is
the bigimage.jpg can't be seen correctly.

This I do not want, I want smallimage.jpg to mantain it's smaller size
on center of bigimage.jpg and it's four border sides to be
transparent, and have it
morph and disappear in 8 frames, so it looks something like this:

Frame 1
--------------------------------------------------
|                   bigimage.jpg                   |
|                                                             |
|                                                             |
|               --------------------------             |
|               |  smallimage.jpg  |             |
|               |                               |             |
|               |   covers this         |             |
|               |   part of                 |             |
|               |   bigimage.jpg     |             |
|               --------------------------             |
|                                                             |
|                                                             |
|                                                             |
--------------------------------------------------
                           .
                           .
                           .
                           .
Frame 8
--------------------------------------------------
|                   bigimage.jpg                   |
|                                                             |
|                                                             |
|                                                             |
|                                                             |
|                                                             |
|                 smallimage.jpg                 |
|                          has                             |
|                    disappeared                   |
|                                                             |
|                                                             |
|                                                             |
|                                                             |
--------------------------------------------------

This is the code I have, I would appreciate help:

#! /usr/local/bin/ruby -w

   require 'RMagick'
   include Magick

   begin
       img1 = Image.read("smallimage.jpg").first
     rescue Magick::ImageMagickError
       puts "ERROR: " + $! + "\n"
       puts "#{$0}: ImageMagickError - #{$!}"
   end

   begin
       img2 = Image.read("bigimage.jpg").first
     rescue Magick::ImageMagickError
       puts "ERROR: " + $! + "\n"
       puts "#{$0}: ImageMagickError - #{$!}"
   end

   bigmask = Magick::Image.new(img2.columns, img2.rows)
{ self.background_color = "black" }
   bigmask.matte = false

   smallmask = Magick::Image.new(img1.columns, img1.rows)
   smallmask.matte = false

   maskok = Magick::Image.new(img2.columns, img2.rows)
{ self.background_color = "black" }
   maskok.matte = true
maskok = bigmask.composite(smallmask, CenterGravity, OverCompositeOp)


   imagewmask = Magick::Image.new(img2.columns, img2.rows)
   imagewmask.matte = true

   imagewmask = imagewmask.composite(img1, CenterGravity,
OverCompositeOp)
   imagewmask = imagewmask.composite(maskok, CenterGravity,
CopyOpacityCompositeOp)

   img1 = imagewmask

   images = Magick::ImageList.new

   images.push(img1)
   images.push(img2)

   morph = images.morph 8
   morph.delay = 12
   morph.iterations = 3600

   morph.write "morphedimage.gif"
   GC.start

   exit

--------------------------






------------------------------

Message: 2
Date: Mon, 03 Sep 2007 15:00:49 +1000
From: Anthony Thyssen <[EMAIL PROTECTED]>
Subject: Re: [magick-users] Morph two images of different size
To: ImageMagick User List <[email protected]>
Message-ID: <[EMAIL PROTECTED]>

The -morph is not a true 'morph' as you see in movies.  It is only
a color morphing trasnform.  Objects in the image doed not 'move'.

For that you need a much more complex bit of software which allows you
to specify what parts of the first image is to match up to the parts in the final image. That is 'warp' merge the two images as well as color
merge the images.

For that I suggest you look at the Xmorph program.


That is not to say IM can't do that.  It just does not have the
facilities to do this simply. YET.

The newest developments in the Distortion Operators, may in the future
allow things such as true image morphing (pixel warping and well as
color transitions.

The same development will also allow for the (eventual) addition of
panorama image overlaying (overlaying multiple photos of a scene to
create a larger image), though that will also require 'image
registration' to locate simular point pairing for distorted overlays.

For some examples of new additions in distortions see.

  General Distortion Operators
     http://www.imagemagick.org/Usage/distorts/#distort

At this moment I am working on additional sub-functions for a major
quality improvement in the output results.


  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
---------------------------------------------------------------------- -------
    `` I've heard of  hunt-and-peck  typing,
                           but his is more  search-and-destroy! ''
---------------------------------------------------------------------- ------- Anthony's Home is his Castle http://www.cit.gu.edu.au/ ~anthony/

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to