Equirectangular to rectilinear projection - FoxelSA/libgnomonic GitHub Wiki
Overview
The library offers a generic algorithm for gnomonic projection allowing to compute rectilinear images from equirectangular mappings or single tiles extracted from an entire mapping. Formally, all other implemented gnomonic projection features are simple front-ends to this last generic algorithm.
The library offers three different ways of obtaining rectilinear images from equirectangular mappings, each offering a specific simplification of the parameters needed by the generic algorithm. The first simplification is offered by the centered-specific projection that assume a gnomonic projection center that corresponds to the center of the computed rectilinear image.
The second simplification is related to equirectangular mapping tiles coming from post-processed Elphel camera sensor images. This front-end to the generic algorithm waits parameters that correspond to Elphel calibration standards and performs the conversion between Elphel-specific frame and the library frame.
The third simplification expects an entire equirectangular mapping to compute a rectilinear image that is defined by three direction angles and an horizontal apperture angle. The vertical apperture angle is deduced considering the desired rectilinear image width and height ratio. The focal length and pixel size of the rectilinear image are also deduced from rectilinear image size and projection apperture angles.
The generic algorithm, and so all of its front-ends, can handle rgb and rgba images. If the input image has no alphal channel, a rgb to rgb drawing is performed. If the input image has an alpha channel, it is used as input transparency (zero being perfect transparency of source pixels). Moreover, the alpha channel of the input image is drawn in the alpha channel of the rectilinear output image when available.
Demonstration
To illustrate the results of the gnomonic projection algorithms provided by the library, the following entire equirectangular mapping (copyright (c) Didier Mouron under CC BY-SA license) captured using an Eyesis4Pi camera is considered :
An equirectangular tile is extracted from the entire mapping and is given by the following image :
Using the generic gnomonic projection algorithm with an azimuth angle of 45 degrees and elevation and roll angles set to zero, a focal length of 7 mm, a pixel size of 0.05 mm and a shift of the gnomonic projection center of 10 pixels in both direction according to rectilinear image center, the following rectilinear image is obtained :
With the considered equirectangular tile and the provided projection parameters, each pixel of the rectilinear image has an antecedent on the equirectangular tile. When this condition is not satisfied, the rectilinear pixels without equirectangular antecedents are left untouched.
Considering now the entire equirectangular mapping and the apperture-specific gnomonic projection algorithm and taking 270 degrees as azimuth angle, zero for both elevation and roll angles and an apperture of 90 degrees, the following rectilinear image is obtained :
Adding a specific alpha mask to the equirectangular mapping and performing the same gnomonic projection taking the previous rectilinear image as initialization, the following rectilinear image correction can be made using algorithm alpha channel management :
The couch as now a much more epic color.