Page 1 of 1

Floating point pixel coordinates

Posted: 2015-03-18T11:32:07-07:00
by pulsar
I had very little experience with ImageMagick C API in the past, mostly by means of finding a similar example code and adopting it to my needs, but now I am trying to accomplish a project in which I don't even know if it is doable with ImageMagick, and don't know where to start.

In short, I want to do my own (fairly complex) warping/distortion of images. I have all the math. What I need is a way to read color information (r,g,b,alpha) for floating point pixel coordinates in the input image. The color should be computed by ImageMagick using an interpolation from the neighboring pixels.

I do see the interpolation discussed here: http://www.imagemagick.org/Usage/misc/#interpolate , where the functionality I need (floating point pixel coordinates) is described. But this is not for C API, just for command line.

Is floating point pixels coordinates (get color via interpolation) feature supported by C API? In MagickWand, I could only find get color methods which use integer pixel coordinates (PixelWand). I couldn't find anything relevant in MagickCore description.

Thank you very much for any feedback!

Re: Floating point pixel coordinates

Posted: 2015-03-18T12:12:52-07:00
by snibgo
pulsar wrote:Is floating point pixels coordinates (get color via interpolation) feature supported by C API?
Yes. I use InterpolateMagickPixelPacket(...), defined in pixel.h. This respects the -virtual-pixel and -interpolate settings. See examples in http://im.snibgo.com/customim.htm

Re: Floating point pixel coordinates

Posted: 2015-03-18T12:18:01-07:00
by pulsar
snibgo wrote:
pulsar wrote:Is floating point pixels coordinates (get color via interpolation) feature supported by C API?
Yes. I use InterpolateMagickPixelPacket(...), defined in pixel.h. This respects the -virtual-pixel and -interpolate settings. See examples in http://im.snibgo.com/customim.htm
That's perfect - your link even contains an example code! Thank you very much!