How to distort like expansion/compression of "japanese fan"?

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
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

How to distort like expansion/compression of "japanese fan"?

Post by pipitas »

I'd like to get some help in achieving a specific distortion I have in mind. It's a bit difficult to me to explain in English words what exactly I mean (I'm not a native speaker), though the idea is quite clear in my mind.

Think about an image with quadratic dimensions and a center point. Imagine around this center point there is a area in the shape of a "japanese fan" (see this link for some images: http://www.google.de/search?num=10&hl=d ... tQacq7HoBg ).

The distortions I want make to the pixel area are just analog to the movement a japanese fan makes when widened or narrowed a bit. I want to do expansions or reductions of the "span of the fan" by about 10% each.

I want to do it on the commandline. My IM version is '6.7.8-0 2012-07-12 Q16' (installed on a Mac OS X Lion via 'MacPorts'), . It looks like the available distortions for

Code: Select all

'-distort arc' 
'-distort polar'

would well suit for such things. But I couldn't, after a full weekend of trying, not figure out the parameters to use so that I get some sort of arc-ish expansion or compression around the center of the image. I guess it is of no use to list all the command variations I've tried. OK, so that you do believe me I tried it, I'll give you one command:

Code: Select all

convert 100pc.pdf +distort arc "60 0 288 0" -repage +288+288  out.png
which was the closest I could get to my desired result.

I was, however, successful in "bending" an originally rectangual image into a circular shape (and back to the original shape), similar to this (as demonstrated by Anthony Thyssen in the 'Usage' pages):
Image
But I was not able to apply my wanted, very similarly looking distortion against my pictures. So... I'll not list the many dozen of my failing command variations.

Instead I've created a GIF animation to better explain the things I want to achieve. (This is *not* the result of an animation -- instead I've handwritten some PostScript code to create the '100%', '90%' (10% 'fan compression' and '110%' (10% 'fan expansion') images and used those for image-magicking the GIF:

https://www.dropbox.com/sh/5wmtshihvgvi ... wanted.gif
Image

And here is one of the source files I used to create that GIF (actually it's a model for the ones I want to expand and compress by 10% 'like a japanese fan'):

https://www.dropbox.com/s/8ol5d25ezkpm5tz/100pc.pdf

Is such a type of distortion at all possible? What am I doing wrong? Any suggestions how to tackle this task?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to distort like expansion/compression of "japanese f

Post by fmw42 »

try the following on this image:

Image

convert zelda3.jpg -flip -virtual-pixel Black -background Black +distort Polar '128,0 0,0 -60,60' -flip zelda3_fan60.jpg

Image


convert zelda3.jpg -flip -virtual-pixel Black -background Black +distort Polar '128,0 0,0 -120,120' -flip zelda3_fan120.jpg


Image
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: How to distort like expansion/compression of "japanese f

Post by pipitas »

fmw42 wrote:try the following on this image:

Image

convert zelda3.jpg -flip -virtual-pixel Black -background Black +distort Polar '128,0 0,0 -60,60' -flip zelda3_fan60.jpg

Image
Hi fmw42,

thanks for the very fast reply. Did you have a chance look at my files? (I'm not sure if these are accessible to 'outsiders' at all though I 'shared' them -- I created that dropbox account only a few hours ago, just to upload and share them with this forum...)

Yes, I could get a similar effect like the 'zelda fan' thing.
  • However, your example looks to me that the 'center' point of the fan is at the bottom of the original picture.
  • But what I want for mine, is that the 'center' point is in the center of the original picture, and the 'fan expansion' happening around that one...
Cheers,
pipitas
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to distort like expansion/compression of "japanese f

Post by anthony »

pipitas wrote:
  • However, your example looks to me that the 'center' point of the fan is at the bottom of the original picture.
  • But what I want for mine, is that the 'center' point is in the center of the original picture, and the 'fan expansion' happening around that one...
That does not make any sense....
Both arc and polar are rectangular to polar distortion, the 'center' for a rectangular area is usually either the top or bottom edge of the image.

UNLESS!!!!!

To have a center in the starting image, that image must already be in polar coordinates. That is you are starting with a fan image (whcih you did not mention, but assumed we knew), and want to actually make the EXISTING fan image open and close.

For that you need two distorts, de-polar and then polar. de-polar to rectangular coordinates, then polar, using different angles.

See the De-polar-Polar cycle examples.
http://www.imagemagick.org/Usage/distorts/#polar_tricks

Suggestion do the de-polar once only (with scaled enlargement), then always polar distort that image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: How to distort like expansion/compression of "japanese f

Post by pipitas »

anthony wrote: That does not make any sense....
Both arc and polar are rectangular to polar distortion, the 'center' for a rectangular area is usually either the top or bottom edge of the image.

UNLESS!!!!!

To have a center in the starting image, that image must already be in polar coordinates. That is you are starting with a fan image (whcih you did not mention, but assumed we knew)
Well, that's why I sent the links to the dropbox files, so it would be clear what exactly we are talking about... :) To be sure, the original images were *NOT* defined in polar coordinates (but they could be looked at such as if they *were* made so...
anthony wrote:, and want to actually make the EXISTING fan image open and close.

For that you need two distorts, de-polar and then polar. de-polar to rectangular coordinates, then polar, using different angles.

See the De-polar-Polar cycle examples.
http://www.imagemagick.org/Usage/distorts/#polar_tricks
Suggestion do the de-polar once only (with scaled enlargement), then always polar distort that image.
I've tried this already and didn't succeed. Will try harder after I wake up again....
Post Reply