Posts

Showing posts from February, 2023

Assignment 1.2 - Transformation

Images:  https://drive.google.com/drive/folders/1yCfFEXnEinsWBNejbDgEsziCHdESol1D?usp=share_link Code import numpy as np import matplotlib.pyplot as plt import cv2 grayImage = r'albert-einstein_gray.jpg' colourImage = r'tulips.jpg' I_gray = cv2.imread(grayImage,cv2.IMREAD_GRAYSCALE) I_BGR = cv2.imread(colourImage) plt.imshow(I_gray,cmap='gray') plt.imshow(I_BGR[:,:,::-1]) #scaling I_gray_resized = cv2.resize(src=I_gray,fx=2,fy=2,dsize=None) plt.imshow(I_gray_resized,cmap='gray') # plt.xticks([]) # plt.yticks([]) I_gray_resized.shape I_gray.shape I_BGR_resized = cv2.resize(src=I_BGR,fx=0.5,fy=2,dsize=None) plt.imshow(I_BGR_resized[:,:,::-1]) #Rotation  image = cv2.rotate(I_gray , cv2.ROTATE_90_CLOCKWISE) plt.imshow(I_gray_rot,cmap='gray') # access height and width of the image height, width = I_gray.shape # define center of rotation cr = (width/2,height/2) # get the rotation matrix M = cv2.getRotationMatrix2D(cr,30,1) # apply warpAffine() method t