0

Image Shearing

Unsolved
Computer Vision

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

Apple
Facebook
Google
Netflix

Image Shearing is one of the affine transformations in digital image processing involving shifting certain part of the image in a certain direction. 

We can convolve the shearing filter (below) around the input pixels to perform image shearing.

\(\begin{bmatrix} 1 & 0.5 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\\ \end{bmatrix}\)

Write a function shear(image) which takes in an grayscale image (represented as 2D numpy array) as input and returns the 
resultant image after image shearing. The output image should have the shape same as that of input image. 

Sample Input:
<class 'numpy.ndarray'>
image: [[ 1 7 119 13 12] [ 11 21 61 81 91] [ 5 66 6 5 5] [ 5 66 166 145 155] [ 5 66 136 145 155]]

Expected Output:
<class 'numpy.ndarray'>
[[ 27 78 230 144 57] [ 79 61 76 207 106] [ 73 276 255 293 163] [ 73 240 445 378 237] [ 5 71 202 311 300]]

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.

Nostrum ea consectetur aliquid? Dicta nam deleniti perspiciatis veniam nulla asperiores, veniam nam placeat labore repellendus eos doloribus, ducimus quisquam commodi rerum reiciendis, veniam quaerat temporibus voluptate ipsa a reiciendis. Nam quaerat id voluptates, dignissimos fugiat quis aliquam, sunt recusandae soluta numquam et eligendi perferendis quo quis. Iure nesciunt minus non autem minima similique doloremque officia quo, quibusdam sunt maiores vero.

Tenetur veniam architecto libero consequuntur vel nesciunt, suscipit quibusdam qui ratione consectetur. Commodi dignissimos ad quidem sapiente facilis ducimus, quibusdam reprehenderit velit architecto, nemo quo dignissimos sint iusto optio itaque? Commodi officia corporis voluptate. Culpa ab nostrum quasi illo aliquid.

Tempore soluta tenetur quo illum cum doloribus nemo, harum magnam earum non minus commodi fuga voluptatum?

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)