Re: [GM-help] Jittery rotate operation -- help with SRT operations
Swiss army knife of image processing
Brought to you by:
bfriesen
From: Bob F. <bfr...@si...> - 2013-09-11 14:07:31
|
On Tue, 10 Sep 2013, Jonathan Haws wrote: > All, > > I am having troubles using Magick++ to rotate an image about its center. Here is what I have right now: > > img.rotate(rotation); > uint32_t xoff = (img.size().width() - m_image.img.size().width()) / 2; > uint32_t yoff = (img.size().height() - m_image.img.size().height()) / 2; > Magick::Geometry newsz(m_image.img.size().width(), m_image.img.size().height(), xoff, yoff); > img.crop(newsz); > img.write(&blob); > > However, what I am seeing is what is shown in this ImageMagick forum post: > > http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=17792#p67335 > > Notice the jitter in the first Koala...I am seeing exactly that. > > However, what I am having trouble finding is information on how to perform a SRT operation on the image to remove that. Can anyone here help point me in the right direction? GraphicsMagick does not (and likely will never) support ImageMagick's distortion algorithm since it was developed by Anthony Thyssen over several years strictly for ImageMagick and not contributed to GraphicsMagick. I expect that by understanding the image output by GraphicsMagick's rotate (it creates a larger square image wholely containing the rotated original) that an intelligent crop can be added to eliminate the jitter. The key is to compute the coordinates of the center so the crop is correct. First one would want to composite the original image onto the center of a larger square canvas (e.g. white) image so that the image can be repeatedly rotated and cropped without losing any of the original image content. I think that you would want to perform the same composite, rotate, crop operation for each step of the rotation. ImageMagick's distortion/warping algorithm is exceedingly slow so a relatively clumsy algorithm based on rotate (which is itself a bit clumsy, as Anthony describes in his forum posting) is likely to still be considerably faster. Bob -- Bob Friesenhahn bfr...@si..., http://www.simplesystems.org/users/bfriesen/ GraphicsMagick Maintainer, http://www.GraphicsMagick.org/ |