MATLAB exercise program (ARC projection)

Source: Internet
Author: User

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, []);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.