Programming Assignment 1
Programming Assignment 1
Q1]
A = [1 1; 1 3] and b = [4; 0]
Shear factor k = 1
Scaling factors sx = 2, sy = 2
The code applies a series of affine transformations (shear, rotation,
scaling, and translation) to an image step by step. The key steps are:
The transformations are applied one after the other or merged into a
single matrix. The algorithm does these transformations using matrix
multiplication and warps the image using cv2.warpAffine(). Pixel values in
the altered image are smoothed using bilinear interpolation. Each
modification is applied, and the final image is trimmed to get rid of extra
white space. The resultant output for both a genuine image and a simple
square shows the combined effect of these modifications.
Procedure/Algorithm
o Half Mask: Value of 1 for the left half and 0 for the right.
6.
Observations and Results
Reasoning
Masking: Using masks allows for flexible control over which image
dominates at each part of the final blend, resulting in aesthetically
pleasing transitions.
Q2] This algorithm projects an image through a camera model defined by
the given projection matrix P using a series of rotations to extract intrinsic
(K) and extrinsic (R) parameters. The camera centre in world coordinates
is also computed. The final step involves using the camera's intrinsic
matrix (K) and projective transformations to map an old image onto a new
image plane.
Step-by-Step Explanation:
The submatrix M is the 3x3 part of P, which contains the camera's rotation
and intrinsic parameters.
o Z-axis rotation (R3): The final rotation aligns the matrix with
the Z-axis.
After applying all three rotations, the final rotation matrix R is derived by
multiplying R1, R2, and R3.
Here, Q is the product of M and the extracted rotations, and p4 is the last
column of the projection matrix P. This gives the location of the camera in
world space.
Image Projection:
o We take an image and project each pixel from the image onto
the new image plane using the intrinsic matrix K.
o The pixel values are mapped to the new image plane based on
the calculated projection coordinates.