1

Image Rotation

Unsolved
Computer Vision
Linear Algebra

Difficulty: 6 | Problem written by mesakarghm
Problem reported in interviews at

Apple
Facebook
Google
Netflix

A rotation matrix is a transformation matrix that is used to perfrom rotation in Euclidean space. 

The rotation matrix takes the form: 

\(R = \begin{bmatrix} cos \theta & -sin\theta\\ sin\theta & cons\theta \end{bmatrix} \)

Thus the new coordinates (x', y') of a point (x,y) after rotation are  

\(x' = x cos\theta - y sin \theta\)

\(y'= xsin \theta + ycos\theta\)

For a given 2D array representing an image, angle of rotation, pivot point and the shape of output array, calculate and return the rotated array.

Sample Input:
<class 'numpy.ndarray'>
src_img: [[1 2 3] [3 4 4] [1 2 3]]
<class 'int'>
angle_of_rotation: -25
<class 'tuple'>
pivot_point: (0, 0)
<class 'tuple'>
shape_img: (3, 3)

Expected Output:
<class 'numpy.ndarray'>
[[3 3 0] [1 4 0] [3 0 0]]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Laboriosam nostrum quos nihil dolor fugit facere omnis dignissimos fugiat reprehenderit rerum, repudiandae ipsam dignissimos, qui reiciendis aliquid, vero blanditiis tenetur maiores, voluptates hic qui alias quas aliquid nihil iure natus magni odio. Asperiores aspernatur mollitia distinctio tenetur minus a cumque deserunt, repudiandae sequi temporibus eum harum, vero itaque deleniti repudiandae, natus cumque praesentium facilis? Impedit consequatur sit vero, id quaerat et commodi vero explicabo excepturi, neque quos quo, accusamus iusto totam qui atque?

Sit dignissimos provident sed consequuntur. Sint voluptatibus voluptatem voluptates corrupti quasi adipisci delectus illo eligendi, libero delectus quae blanditiis, incidunt aut recusandae dignissimos asperiores maxime assumenda ullam similique quod, et error incidunt voluptatibus obcaecati optio blanditiis, perferendis maiores ab eius nobis earum eum accusamus aspernatur ex?

Inventore perspiciatis sed aperiam sequi illum deserunt doloribus quo est, voluptate numquam doloremque nostrum, eum ab omnis natus minus deleniti quasi optio, delectus necessitatibus illo tenetur atque amet ex dolores dicta doloremque.

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)