3

Given an photographical image of a sphere, i.e. an circle with radius $r$ quantized into uniform, square pixels, how can one calculate the equivalent area of the sphere covered by each pixel?

I'm assuming that the projection is parallel.

Example: Let a sphere of radius $R = 1$ be projected to a circle with a radius of $r = 100\,\mathrm{px}$, where the center of the sphere is the center of the middle pixel $(50, 50)$ in the image.

Basically I'm interested in the reverse projection from the pixel space to the sphere.

I guess I have to cast rays from the corners of the pixel onto the sphere and from those four points get the area of the sphere in the section that is encased in the four points.

Sketch of the setup.

  • The answer will vary depending on which pixel you're looking at.. Is this really what you're looking for? – Bobson Dugnutt Apr 19 '17 at 10:12
  • I am especially interested in the difference of the areas covered by the pixels. I need to solve an engineering problem, were I have to calculate a metric based on the spherical area from image data. This is why I need to normalize the areas with respect to the pixel positions.

    Say, I have a Sphere that has a black painting, which has some white spots. I want to calculate the ratio of white to black area on the sphere from the image.

    – Finn Poppinga Apr 19 '17 at 10:16
  • Since you're only interested in the ratio, and is - I assume - looking for an approximation, this might very well be doable. I'll think about it and post if I find anything. – Bobson Dugnutt Apr 19 '17 at 10:32
  • Does this need to work for pixels that are on or near the edge of the image of the sphere? At the edge of that image, you have pixels that are not completely "on" the sphere, that is, each such pixel is some combination of the image of the sphere and the image of whatever is behind the sphere. – David K Apr 19 '17 at 10:53
  • @DavidK No, I don't think we have to handle that case, as the border of the circle is small compared to the total area. – Finn Poppinga Apr 19 '17 at 11:28
  • But pixels projected near the edge of the circle will correspond to the largest areas. – Bobson Dugnutt Apr 19 '17 at 11:30
  • Well here's something: With one dimensional "pixels" with length $x$, the arclength of the projection onto the circle from the $n$th pixel away from the line going through the center of the circle is given by $(\theta_n-\theta_{n-1})r=\left(\arcsin\left(\frac{nx}{r}\right)-\arcsin\left(\frac{(n-1)x}{r}\right)\right)r$, which can then be generalized to the surface area, see for instance here. – Bobson Dugnutt Apr 19 '17 at 11:47

1 Answers1

2

An area element in spherical coordinates is given by $$\mathrm d A=r^2\sin\phi \mathrm d\phi \mathrm d\theta,$$ following the convention shown here:

enter image description here

Place your sphere at the origin and say your projection is orthogonal to the $x,y$-plane, i.e. parallel to the $z$-axis. You now have a pixel. Let its bottom-left corner (as seen in the $x,y$-plane) have coordinate $(nd,md)$ with $d$ being the pixel width and $|n|,|m|<\frac{r}{d}$. You now project this pixel onto the sphere and want to know what the corresponding area on the sphere is. To do this, simply integrate the above mentioned area element over the limits in spherical coordinates corresponding to the change in $x$ and $y$, being $x_1=nd\rightarrow x_2=(n+1)d$ and $y_1=md\rightarrow y_2=(m+1)d$ respectively. However, we want to find these limits in terms of $\theta$ and $\phi$, i.e. $\theta_1,\theta_2$ and $\phi_1,\phi_2$, so that we can calculate the projected area of pixel $n,m$ by $$A_{nm}=\int_{\phi_1}^{\phi_2}\int_{\theta_1}^{\theta_2}\mathrm d A.$$ We have that

\begin{align} \theta&=\arctan\left(\frac{y}{x}\right) \\ \phi&=\arccos\left(\frac{z}{r}\right). \end{align}

Now, the $\theta$-part is easy enough, as \begin{align} \theta_1&= \arctan\left(\frac{m}{n}\right)\\ \theta_2&= \arctan\left(\frac{m+1}{n+1}\right). \end{align}

However, the $\phi$-part requires knowledge of $z$, but since we are always only projecting onto the surface of the sphere, we know that $$x^2+y^2+z^2=r^2 \implies z=\sqrt{r^2-x^2-y^2},$$ (note that I've chosen the positive solution... If I were you, I would rotate my coordinate-system each time you're working with pixels lying outside of the first quadrant)

which gives \begin{align} z_1&=r\sqrt{1-\frac{d^2}{r^2}(n^2+m^2)} \\ z_2&=r\sqrt{1-\frac{d^2}{r^2}((n+1)^2+(m+1)^2)}. \end{align} But with this, we can calculate the remaining limits:

\begin{align} \phi_1&=\arccos\left(\sqrt{1-\frac{d^2}{r^2}(n^2+m^2)}\right)\\ \phi_2&=\arccos\left(\sqrt{1-\frac{d^2}{r^2}\left((n+1)^2+(m+1)^2\right)}\right), \end{align}

such that the integral evaluates to

\begin{align} A_{nm}&=r^2(\theta_2-\theta_1)(\cos\phi_1-\cos\phi_2)\\ &= r^2\left(\arctan\left(\frac{m+1}{n+1}\right)-\arctan\left(\frac{m}{n}\right)\right)\left(\sqrt{1-\frac{d^2}{r^2}(n^2+m^2)}-\sqrt{1-\frac{d^2}{r^2}\left((n+1)^2+(m+1)^2\right)}\right) \end{align}

In conclusion, this is a formula for the area of the pixel with $x,y$-coordinates $(nd,md)$ projected onto a sphere that has center at the origin and radius $r.$ Do this for every pixel whose projection is completely on the sphere (the formula does not work otherwise) and you can find your desired ratio.

Doing concrete calculations with this requires care w.r.t. principal values and such, but as I mentioned, I'd strongly recommend rotating your coordinate system when working with the pixels lying in other quadrants of the $x,y$-plane than the first.

Do leave a comment if you have any questions.

  • 1
    @FinnO Did this answer your question? If not, let me know. If it did, you can "accept" the answer, by clicking the little checkmark right below the up/down-vote buttons. This will give both answerer and questioner a rating-boost, and clear the question from the "unanswered"-queue. – Bobson Dugnutt Apr 27 '17 at 12:26