Image Crop

Computer Vision

Difficulty: 2 | Problem written by zeyad_omar
Problem reported in interviews at


In deep learning and computer vision, the images may contain unwanted details. For example, if we are designing a face recognition model by feeding images to the model and getting the name of the preson in the photo, it would be unnecessary to feed the model with an image of size (4000,4000,3) while the person's face is only of size (100,100,3), so we need to crop the image to save time, money, and effort.

In this problem you are given an image and you are asked to crop the rectangle whose upper left corner is (x1,y1) and whose lower right corner is (x2,y2).

Sample Input:
<class 'list'>
image: [[1, 1, 1, 1], [1, 1, 1, 0]]
<class 'int'>
x1: 0
<class 'int'>
y1: 0
<class 'int'>
x2: 1
<class 'int'>
y2: 1

Expected Output:
<class 'numpy.ndarray'>

This is a premium problem, to view more details of this problem please sign up for MLPro Premium. MLPro premium offers access to actual machine learning and data science interview questions and coding challenges commonly asked at tech companies all over the world

MLPro Premium also allows you to access all our high quality MCQs which are not available on the free tier.

Not able to solve a problem? MLPro premium brings you access to solutions for all problems available on MLPro

Get access to Premium only exclusive educational content available to only Premium users.

Have an issue, the MLPro support team is available 24X7 to Premium users.

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

Log in to post a comment


Input Test Case

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