Animation, but not floating point?

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?".
Locked
snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Animation, but not floating point?

Post by snibgo »

I'm using 6.5.8-Q16 on Windows 7, seeing how suitable IM might be for generating frames for a movie from photographs using pan/zoom/etc.

A typical command pastes part of an image to a background:
composite -compose Copy -geometry +22.53+10.673 ( srcB.jpg -resize "54.9399%" ) iv_bgnd.png iv_srcB.png

iv_srcB.png is then blended with other images to make a frame. Frames are assembled with ffmpeg.

The geometry and resize numbers are calculated by software, and change smoothly between frames.

But composite seems to read the geometry offsets as integers, not floating point. So a point on a photo won't move smoothly, but jerks with the quantisation.

Is this a problem in the API, or just the command lines? Are there plans to fix this? Or have I got something wrong?
snibgo's IM pages: im.snibgo.com

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Animation, but not floating point?

Post by snibgo »

To answer my own question: I have now looked at the APIs and source code. It seems that pixels are addressed by "unsigned long". This also applies to resizing, so zooming in will also result in quantisation jerks.

Of course, IM is geared towards the production of individual images, rather than frames for a movie. Changing it for floating point adressing of pixels wouldn't be trivial, especially without changing the APIs. The developers may wish to consider this for IM's long-term development.

I may redirect my efforts to generating frames in ActionScript, which does have floating point adressing (but has other problems, of course).
snibgo's IM pages: im.snibgo.com

User avatar
anthony
Posts: 8884
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Animation, but not floating point?

Post by anthony »

Just to clarify and complete this old topic (made while I was away in china.

Many things in image processing is restricted to integers (or longs) Sometimes signed, sometimes unsigned.

Image size for example must be unsigned integers. You can not have half pixel images!
Similarly image page offsets, geometry etc much be in whole pixels, though the position can be negative.

however that does not mean you can not 'translate' an image to a faractional offset! this however requires you to distort the image so that the image becomes re-interpolated (or filtered) to allign it to a grid at the new position.

See Im examples, Affine Distorts
http://www.imagemagick.org/Usage/distorts/#affine
also Affine translations....
http://www.imagemagick.org/Usage/distor ... fine_trans

Resizing also limits itself to whole integers. Though again you can distort an image to fractional sizes. See Resize using distort
http://www.imagemagick.org/Usage/resize/#distort
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Animation, but not floating point?

Post by snibgo »

Yes, I should have put a closing statement here.

I use "-distort SRT" to generate frames for totally smooth panning and zooming to non-integer pixel boundaries. "-distort perspective" also works well.
snibgo's IM pages: im.snibgo.com

Locked