This is actually a cylindrical projection, but in the previous article, we saw the convex result from the front, and the concave result was obtained from the back.
The formula is left blank. For a general introduction, the X coordinate calculation method in the formula is the same as that in the previous article. The Y coordinate is exactly the inverse transformation of the previous formula, combining the formula code in the previous article and the code in this article should not be difficult to understand.
The following is the transformation result obtained when HFOV is PI/2:
Source image:
Result:
The Matlab code is as follows:
Clear all; close all1_clc1_img1_imread('lena.jpg '); [h, w] = size (IMG); HFOV = PI/2; % optional range: (0, Pi) F = W/(2 * Tan (HFOV/2); X1 = 0; x2 = floor (2 * f * atan (W/(2 * F ))); y1 = floor (H/2-h * (SQRT (W/2) ^ 2 + f ^ 2)/(2 * f )); y2 = floor (H/2 + H * (SQRT (W/2) ^ 2 + f ^ 2)/(2 * F); newh = y2-y1; NEWW = x2-x1; imgn = zeros (newh, NEWW); for I = 1 + Y1: newh + Y1 for j = 1: NEWW % apply the inverse transformation formula X = floor (F * Tan (J/F-atan (W/(2 * F) + W/2 ); y = floor (H/2 + F * (I-H/2)/SQRT (f ^ 2 + (W/2-x) ^ 2 )); if X> = 1 & x <= W & Y> = 1 & Y <= H imgn (i-y1, j) = IMG (Y, X ); end endendimshow (IMG); figure; imshow (imgn, []);