Equirectangluar to Little/Tiny Planet/Sky photos?

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

Equirectangluar to Little/Tiny Planet/Sky photos?

Post by mhulse »

Hello,

I have an equirectangular photo that I would like to convert to little/tiny planet and sky.

I can get the polar coordinate style, to create a tiny planet, by doing:

convert in.jpg -distort Arc 360 out.jpg

But I was curious, is there a better way to do this?

I don't think polar coords are true stereographic projection?

This article does a good job at explaining what I would like to do:

https://math.stackexchange.com/a/2110192/454666

Anyone here experiment with this?

Thanks!
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: Equirectangluar to Little/Tiny Planet/Sky photos?

Post by fmw42 »

I have some bash unix shell scripts that convert fisheye views (fisheye, defisheye, fisheye2pano, fisheye2rect), but they are mostly going the other way, from vertically fisheye to horizontal views. See my scripts at the link below. However, they are slow in imagemagick due to having to use a very slow -fx. I have converted some of them to compiled -process functions, but have not published them. The closest I have is from a planar perspective to a fisheye view. But that is not quite what you want. I do have a perspective to spherical projection also (see spherize).

See also http://paulbourke.net/dome/2fish/
mhulse
Posts: 61
Joined: 2016-03-17T18:46:22-07:00
Authentication code: 1151

Re: Equirectangluar to Little/Tiny Planet/Sky photos?

Post by mhulse »

fmw42 wrote: 2017-08-04T22:25:43-07:00 I have some bash unix shell scripts that convert fisheye views (fisheye, defisheye, fisheye2pano, fisheye2rect), but they are mostly going the other way, from vertically fisheye to horizontal views. See my scripts at the link below. However, they are slow in imagemagick due to having to use a very slow -fx. I have converted some of them to compiled -process functions, but have not published them. The closest I have is from a planar perspective to a fisheye view. But that is not quite what you want. I do have a perspective to spherical projection also (see spherize).

See also http://paulbourke.net/dome/2fish/
Awesome! Thank you so much for your help Fred! I greatly appreciate it!

I am looking at your scripts now. I'm sure those will give me some excellent starting points.

Also, thanks for the linkage Paul Bourke site, that's looking interesting as well.

I'll post back here if come up with anything new. :)
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: Equirectangluar to Little/Tiny Planet/Sky photos?

Post by fmw42 »

mhulse wrote: 2017-08-04T21:57:57-07:00 Hello,

I have an equirectangular photo that I would like to convert to little/tiny planet and sky.

I can get the polar coordinate style, to create a tiny planet, by doing:

convert in.jpg -distort Arc 360 out.jpg

But I was curious, is there a better way to do this?

I don't think polar coords are true stereographic projection?

This article does a good job at explaining what I would like to do:

https://math.stackexchange.com/a/2110192/454666

Anyone here experiment with this?

Thanks!
Using the process from http://www.photographymad.com/pages/vie ... ama-worlds and the image from https://www.flickr.com/photos/rudolf_sc ... otostream/

Image

And with the following command (unix syntax), using -distort polar to wrap the image into a circle (see http://www.imagemagick.org/Usage/distorts/#polar):

Code: Select all

rollx=`convert xc: -format "%[fx:round(3987/2)]" info:`
convert 417327148_158bf17bf1_o.jpg \( -size 3987x100 gradient:"#B4F2FE-none" \) \
-gravity north -compose over -composite -rotate 180 -roll +${rollx}+0 \
-virtual-pixel HorizontalTile -background "#B4F2FE" \
+distort Polar 0 417327148_158bf17bf1_o_tiny_planet.jpg
I get:

Image

This is not a true stereographic projection. See https://en.wikipedia.org/wiki/Fisheye_lens. I believe it is equivalent to a linear fisheye projection, rather than a stereographic fisheye projection.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Equirectangluar to Little/Tiny Planet/Sky photos?

Post by fmw42 »

I wrote a shell script to convert to several fisheye formats: linear (same as above), stereographic and orthographic simply in order to see what the difference are. The script uses -fx, so it is a bit slow (about 30 sec to process the input image above). Here are the results using a simple white background color. The original command above using -distort polar is very quick and I will probably create a new script just for that for my web site.

Linear (same geometry as above using -distort polar):
Image

Stereographic:
Image

Orthographic:
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Equirectangluar to Little/Tiny Planet/Sky photos?

Post by fmw42 »

I have created a new script, pano2fisheye, to do the above and more. It will be somewhat slow due to the use of -fx. You can find it at my link below.

Next, I will make one that is similar, but only does the linear fisheye and will be very fast.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Equirectangluar to Little/Tiny Planet/Sky photos?

Post by fmw42 »

I have added a new script, tiny planet, that transforms the spherical panorama to a linear fisheye image. This is much faster than my recent script, pano2fisheye. The new script also allows one to create a spinning planet animation
mhulse
Posts: 61
Joined: 2016-03-17T18:46:22-07:00
Authentication code: 1151

Re: Equirectangluar to Little/Tiny Planet/Sky photos?

Post by mhulse »

fmw42 wrote: 2017-08-12T15:54:53-07:00 I have added a new script, tiny planet, that transforms the spherical panorama to a linear fisheye image. This is much faster than my recent script, pano2fisheye. The new script also allows one to create a spinning planet animation
Wow, thank so much! I can't wait to try it out!!!!

Sorry for my late reply. I didn't get a notification that there were new replies.

Also, I was talking with a buddy today about how ImageMagick can take equirectangular images and make tiny planets using polar coordinates.

For example, using this equirectangular as the input image (sorry, it's not the best image to use as an example, but it's what I had on hand):

Image

Using this command line code:

Code: Select all

convert PgYC9nPaHwkdMwhIHMRYTA.jpg -distort Arc 360 tinyplanet.jpg
I get this:

Image
best free picture hosting

Note that the drawback to polar coordinate technique are the seams in the center of the image:

Image

Using Flexify Photoshop plugin, I can create a "tiny planet" that takes equirectangular input and converts it to stereographic projection output:

Image

Note that the "seams" are not there. To me, this is more desirable than the polar coordinate technique. While in the example above the difference not very noticeable, for other photos is much more obvious that there's a polar "pinched" center point.

Flexify also lets you flip the tiny planet and create a tiny sky effect:

Image

Anyway, thanks so much for the help Fred! I am going to try out your latest scripts this weekend. I'll let you know how it goes!

I greatly appreciate the help!
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: Equirectangluar to Little/Tiny Planet/Sky photos?

Post by fmw42 »

My script pano2fisheye will do equirectangular to stereographic or linear or orthographic fisheye views. But it will be slow due to the use of -fx. In principle, I could speed it up by writing it into a MagicFilter. But that would have to be compiled on the user's system.

My other script tinyplanet, uses -distort Polar as in the code I provided earlier on this post. I do not see an discontinuities. Did you use the -virtual-pixel horizontal_tile? If not that may be the cause of the discontinuity.

The use of -distort arc is of course anther method. Here is what that looks like with my image from above

Code: Select all

convert 417327148_158bf17bf1_o.jpg -distort arc 360 417327148_158bf17bf1_o_arc360.jpg
Image

It seems to be closer to the orthographic projection I showed earlier, but still quite different.
Post Reply