forked from sdoshi983/openCV-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter3.py
More file actions
20 lines (15 loc) · 687 Bytes
/
chapter3.py
File metadata and controls
20 lines (15 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import cv2
import numpy as np
# Resizing and cropping:
img = cv2.imread('resources/images.jpg')
print(img.shape) # while printing, it will be in the form (height, width, bgr index)
cv2.imshow('image', img)
# resizing
resizedImg = cv2.resize(img, (200, 175)) # whereas here, it will be in the form (width, height)
print(resizedImg.shape)
cv2.imshow('resized', resizedImg)
#cropping
croppedImg = img[100:150, 100:200] # No need of any openCV function. Here, it will be in the form [height, width]
cv2.imshow('cropped', croppedImg)
cv2.waitKey(0)
# NOTE: In CV, the form will be width, height but it will be opposite in python(i.e in print function and while cropping)