[solved] Reverse polar coordinates?

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
mhulse
Posts: 61
Joined: 2016-03-17T18:46:22-07:00
Authentication code: 1151

[solved] Reverse polar coordinates?

Post by mhulse »

Hello,

I am using this to make a "tiny planet" or "fisheye" effect (source is equirectangular image):

Code: Select all

magick \
  convert \
  ${args.input} \
  -distort Arc 360 \
  ${args.output}
Just curious if anyone knows if there is a straight forward way of flipping that? So the sky is on the inside and the land on the outside?

I found this this amazing program:

http://www.fmwconcepts.com/imagemagick/ ... /index.php

But I kinda wanted to know if there's a more simple way of just getting the "man hole" effect without the use of a large script? Something like the above single convert statement would be cool. From reading the source of pano2fisheye it looks like there's a lot of temp files and meta data read (and math calculations) before the output is made.

Optimally, I'd love for the "man hole" effect to repeat pixels like the above polar coordinates one-liner does. For example:

Image

Thanks for reading!
Last edited by mhulse on 2019-04-08T23:26:50-07:00, edited 1 time in total.
Homebrew-installed ImageMagick 7.0.8-27 Q16 x86_64 2019-02-12 | macOS Mojave | MacBook Pro
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Reverse polar coordinates?

Post by GeeMack »

mhulse wrote: 2019-04-08T22:17:45-07:00Just curious if anyone knows if there is a straight forward way of flipping that? So the sky is on the inside and the land on the outside?
Rotate the image 180 degrees before the "-distort arc". Then you rotate it back the other way by adding a second argument to the "-distort arc" operation.

Code: Select all

... -rotate 180 -distort arc "360 180" ...
Optimally, I'd love for the "man hole" effect to repeat pixels like the above polar coordinates one-liner does.
You can specify the way the edge pixels act by setting "-virtual-pixel" before a "-distort" operation. By using a setting of "-virtual-pixel edge" it will continue the outermost rows of pixels to the new canvas edges. Find out more at THIS link.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Reverse polar coordinates?

Post by fmw42 »

Is this what you want.

Image

Code: Select all

convert 417327148_158bf17bf1_o.jpg -resize 100x200% \
-virtual-pixel edge -distort polar 0 \
417327148_158bf17bf1_o_manhole.png
Image


or this

Code: Select all

convert 417327148_158bf17bf1_o.jpg -rotate 180 -resize 100x200% \
-virtual-pixel edge -distort arc 360 \
417327148_158bf17bf1_o_manhole2.jpg
Image
mhulse
Posts: 61
Joined: 2016-03-17T18:46:22-07:00
Authentication code: 1151

Re: Reverse polar coordinates?

Post by mhulse »

WOW WOW and WOW!!!!!!!!

That is AMAZING. You guys are genius!

Thank you so much for the help, code examples and guidance! I owe you both several Oregon micro brews. :)

Thank you GeeMack and Fred!!!!
Homebrew-installed ImageMagick 7.0.8-27 Q16 x86_64 2019-02-12 | macOS Mojave | MacBook Pro
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Reverse polar coordinates?

Post by fmw42 »

Try -virtual-pixel mirror or random.
mhulse
Posts: 61
Joined: 2016-03-17T18:46:22-07:00
Authentication code: 1151

Re: Reverse polar coordinates?

Post by mhulse »

fmw42 wrote: 2019-04-08T23:24:33-07:00 Try -virtual-pixel mirror or random.
Mind ..... BLOWN!

A M A Z I N G!

Also, this:

-distort polar 0

Does an amazing job! I love how it doesn't "pinch" the center! I'm going to try and apply that to my tiny planet effect as I love the non-pinched look so much more than the pinched.

Thank you so much!!!!!!! I'm so happy!!!!!!!!!!
Homebrew-installed ImageMagick 7.0.8-27 Q16 x86_64 2019-02-12 | macOS Mojave | MacBook Pro
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: [solved] Reverse polar coordinates?

Post by fmw42 »

You can do similar with -distort arc by reducing the resize on the Height. For example

Code: Select all

convert 417327148_158bf17bf1_o.jpg -rotate 180 -resize 100x125% \
-virtual-pixel edge -distort arc 360 \
417327148_158bf17bf1_o_manhole3.jpg
Image
mhulse
Posts: 61
Joined: 2016-03-17T18:46:22-07:00
Authentication code: 1151

Re: [solved] Reverse polar coordinates?

Post by mhulse »

SO COOL! This is amazing. I am seriously blown away. Until now, I thought only a Photoshop plugin could get this kind of quality result. Thank you so much for your help Fred, I can't thank you enough for showing me all of these tricks! This is just so COOL!!!! :)
Homebrew-installed ImageMagick 7.0.8-27 Q16 x86_64 2019-02-12 | macOS Mojave | MacBook Pro
mhulse
Posts: 61
Joined: 2016-03-17T18:46:22-07:00
Authentication code: 1151

Re: [solved] Reverse polar coordinates?

Post by mhulse »

Just wanted to say thanks again for the help!

I wrote a node module (for a larger OSS project I'm working on) that uses the code Fred posted in this thread. Here's the repo:

https://github.com/mhulse/fisheye

The above module is a work in progress for my own personal use (so, not publishing via npm). Eventually, I have plans to make a node CLI for it.

Anyway, many many thanks!
Homebrew-installed ImageMagick 7.0.8-27 Q16 x86_64 2019-02-12 | macOS Mojave | MacBook Pro
Post Reply