Challenge

Project 1

import cv2
import numpy as np

image = cv2.imread(r'C:\Users\kartudup\Documents\SkillLync\.ipynb_checkpoints\car.png')
height, width = image.shape[:2]
center = (width/2, height/2)

rotate_matrix = cv2.getRotationMatrix2D(center=center, angle=140, scale=1)                 #method to obtain roate matrix
rotated_image = cv2.warpAffine(src=image, M=rotate_matrix, dsize=(width, height))          #warpAffine method to rotate the image

cv2.imshow("rotated image:", rotated_image)
cv2.waitKey(0)
cv2.imwrite('rotated_image.png', rotated_image)                                             #saving rotated image

img =cv2.imread(r'C:\Users\kartudup\Documents\SkillLync\.ipynb_checkpoints\rotated_image.png') #reading the rotated image
size = cv2.resize(img, (0, 0), fx = 0.5, fy = 0.5)                                              #scaling to 50%
cv2.imshow("resized image:", size)
cv2.waitKey(0)
cv2.imwrite("resized_image.png",size)                                                           # saving resized image



image = cv2.imread(r'C:\Users\kartudup\Documents\SkillLync\.ipynb_checkpoints\car.png')
image.shape
rstart=100                                                #crop dimensions
rend=600
cstart=180
cend=500
cropped_image = image[rstart:rend, cstart:cend]
cv2.imshow("cropped image:",cropped_image)
cv2.waitKey(0)
cv2.imwrite("cropped_image.png",cropped_image)                  #saving cropped image
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.