AffineTransformImage + interpolate

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?".
Post Reply
nicolas1

AffineTransformImage + interpolate

Post by nicolas1 »

Hello,

I found that it is impossible to apply affine transform on image with interpolation (filter).

Following code runs forever.

Magick::Image *bitmap_;
MagickLib::Image *resized_;

MagickLib::AffineMatrix _affine;

_affine.sx = 0.1; _affine.rx = 0; _affine.tx = 0;
_affine.sy = 0.1; _affine.ry = 0; _affine.ty = 0;

bitmap_->image()->filter = MagickLib::BoxFilter;
bitmap_->image()->interpolate = MagickLib::FilterInterpolatePixel;

resized_ = MagickLib::AffineTransformImage( bitmap_->image(), &_affine, NULL);

Following code produces non-Bicubic interpolated result:

MagickLib::AffineMatrix _affine;

_affine.sx = 0.1; _affine.rx = 0; _affine.tx = 0;
_affine.sy = 0.1; _affine.ry = 0; _affine.ty = 0;

bitmap_->image()->interpolate = MagickLib::BicubicInterpolatePixel;

resized_ = MagickLib::AffineTransformImage( bitmap_->image(), &_affine, NULL);

How interpolation can be set for affine transform?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: AffineTransformImage + interpolate

Post by anthony »

You could switch to using the DistortImages AffineProjection method instead. This should have a lot more control.

The older affine functions has not been modified to use the new more general distortion method as yet.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply