Crop and Resize
Learn to crop and resize images.
We'll cover the following...
1.
What do you think will happen if we try to read multiple images of a large size ?
Show Answer
Q1 / Q1
Did you find this helpful?
So, what’s the solution?
To solve this issue, we resize the large images into smaller ones.
Find the dimensions of the image
To find the dimensions of the image, we use the img.shape
method of the OpenCV library. Here, img
is the object we’ve stored the image in. Let’s run the program to find the dimensions of the image:
Press + to interact
# Import libraryimport cv2# Loading an imageimg = cv2.imread(r"/usercode/image.jpg")print(img.shape)
In the output, the first parameters are the height and width, respectively. The third parameter is the number of ...