Tiny Planet Algorithm?

2.2k Views Asked by At

So I've recently been looking at the Tiny Planet images.

I've been googling a few things to try and find out how images are converted from normal to a tiny planet. Some phone apps, as well as photoshop do this.

I think Photoshop does it by converting Cartesian coordinates to Polar coordinates. I found a good explanation of converting them here.

However, I am yet to find somewhere that describes an algorithm of the process.

Is there a set formula? or is it more complex than that?

I'm not sure if it's as easy as moving pixels and converting coordinates because I think some form of stretching must be included... hence, looking for an algorithm and this exchange as a resource. Thanks.

2

There are 2 best solutions below

0
On

The article you have linked has "Stereographic Projection" in the title. Here is a link to the relevant part of the Wikipedia article. It is difficult to tell solely from looking at the images, but it seems as if the original photograph (which is a effectively a portion of a plane) is mapped to a hemisphere using a similar transformation. Then, in a second transformation, each point $(x,y,z)$ of the hemisphere is mapped to $(x,y,0)$ so that all of the points lie in a plane. It seems to me that this would create the desired effect.

1
On

The process of creating the images you describe uses a kind of projection called stereographic projection. When you take your panorama photo, it "stores" the data on a sphere so to speak.

$\hspace{45mm}$enter image description here

Our goal is to project that image from the sphere to the plane.

$\hspace{25mm}$enter image description here

As you can see in the image above, the projection of a point is found by taking a line from the north pole through the point you wish to project and finding its intersection with the $z=-1$ plane. Mathematically, this translates to finding a $t$ such that $$\begin{pmatrix}0 \\ 0 \\ 1\end{pmatrix}+t\left(\begin{pmatrix}x \\ y \\ z\end{pmatrix}-\begin{pmatrix}0 \\ 0 \\ 1\end{pmatrix}\right)=\begin{pmatrix}X \\ Y \\ -1\end{pmatrix},t\in\mathbb{R}$$ Here $(x,y,z)$ is the point we wish to project and $(X,Y)$ is the resulting projection. Now, if we look only at the $z$ coordinate, this boils down to solving the following equation $$1+t(z-1)=-1$$ which has the nice and simple soltuion $$t=\frac{2}{1-z}$$ Plugging back into our first equation we get $$\begin{pmatrix}\frac{2x}{1-z} \\ \frac{2y}{1-z} \\ -1\end{pmatrix}=\begin{pmatrix}X \\ Y \\ -1\end{pmatrix}$$ Therefore, the coordinates for the projection is $$(X,Y)=\left(\frac{2x}{1-z},\frac{2y}{1-z}\right)$$ Now, I don't know how the camera's actually store the data for the panorama, but assuming you have access to such an image you can transform that data onto the sphere and apply the projection to get your desired result.

Image source