Rectilinear to equirectangular projection - FoxelSA/libgnomonic GitHub Wiki

Overview

The library offers three different gnomonic projection algorithms as simplified front-ends to the generic algorithm. It also offers an invert to all implemented algorithms. It means that four invert gnomonic projection algorithms are available that invert the generic algorithm and its three front-ends. The invert algorithms are implemented with the exact same prototype, considering the same parameters in the same order, except that the two images are swap in their input and output role.

The management of rgb and rgba images works the same as the direct algorithms, as explained in their documentation page.

Demonstration

Considering the following equirectangular mapping (copyright (c) Didier Mouron under CC BY-SA license) obtained using an Eyesis4Pi camera :

the following equirectangular tile, identical as the tile used in the documentation of the direct algorithms, is extracted :

Using the same gnomonic projection parameters as used in the direct algorithms documentation, the following rectilinear image is computed :

Using the invert of the generic algorithm with the exact same parameters, the following equirectangular tile is obtained :

The obtained image is not the exact equirectangular tile we had in the begining. This is due to the parameters used for computing the rectilinear image that did not consider all the pixels of the equirectangular tile. As a consequence, the invert algorithms are strict inverts of direct algorithms if and only if the rectilinear images are computed with parameters that ensure all equirectangular pixels consideration.

The invert of apperture-specific algorithm can be used to perform correction of the mapping through rectilinear image that does not exhibit equirectangular deformations, specially near the mapped sphere poles. Considering the following rectilinear image :

it is simplier to perform correction using rectangular selection. Using an appropriate alpha mask and the invert of apperture-specific algorithm with the same parameters as those used to extract the previous rectilinear image, the following corrected mapping can be computed :

In order to safely use the inverts of gnomonic projection algorithms, one has to keep in mind that mapping of curves such as sphere are tricky in numerical terms. In our case of equirectangular mappings, both first and last bitmap lines correspond, almost, to the same point of the sphere. Performing successively a gnomonic projection and its invert can lead to differencies without, formally, implying loss of information even when initial and final equirectangular mappings exhibit differencies.