Posts

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...

Assignment 1.1: Image Transformation in Python

  Images:  https://drive.google.com/drive/folders/1yCfFEXnEinsWBNejbDgEsziCHdESol1D?usp=share_link Code:   import numpy as np import matplotlib.pyplot as plt im = np.arange(256) im = im[np.newaxis,:] im = np.repeat(im,100,axis=0) plt.imshow(im,cmap='gray') Processing Grayscale images im = plt.imread(r'albert-einstein_gray.jpg') type(im) im.shape im.dtype plt.imshow(im,cmap='gray') im im[23,300] im2 = im.copy() im2[23,100] = 200 im2[23:100,40:100] = 255 plt.imshow(im2,cmap='gray') im2[300:400,40:100] = 0 plt.imshow(im2,cmap='gray') # Quiz Solution im = plt.imread(r'albert-einstein_gray.jpg') im3 = im.copy() im3[330:430,300:400] = 255 #for left eye im3[330:430,440:540] = 255 #for right eye plt.imshow(im3, cmap='gray') plt.imsave(r'albert-einstein_gray_modified.jpg',im2,cmap='gray') # pip install opencv-contrib-python Grayscale Images in OpenCV import cv2 img = cv2.imread(r'albert-einstein_gray.jpg',cv2.IMREAD...

Assignment 8 - Animation Principal

Image
 Aim: Implement animation principles for any object Theory:  Animation is defined as a series of images rapidly changing to create an illusion of movement. We replace the previous image with a new image which is a little bit shifted. Animation Industry is having a huge market nowadays. To make an efficacious animation there are some principles to be followed. Principle of Animation: There are 12 major principles for an effective and easy to communicate animation. Squash and Strech: This principle works over the physical properties that are expected to change in any process. Ensuring proper squash and stretch makes our animation more convincing. For Example: When we drop a ball from height, there is a change in its physical property. When the ball touches the surface, it bends slightly which should be depicted in animation properly. Anticipation: Anticipation works on action.Animation has broadly divided into 3 phases: 1. Preparation phase 2. Movement phase 3. Fini...

Assignment 7 - Bezier and Koch Curve

Image
 Aim: Generate fractal patterns using i) Bezier ii) Koch Curve Theory: Bezier Curves Properties of Bezier Curves Bezier curves have the following properties        They generally follow the shape of the control polygon, which consists of the segments joining the control points.     They always pass through the first and last control points.      They are contained in the convex hull of their defining control poin ts.      The degree of the polynomial defining the curve segment is one less that the number of defining polygon point. Therefore, for 4 control points, the degree of the polynomial is 3, i.e. cubic polynomial.      A Bezier curve generally follows the shape of the defining polygon.      The direction of the tangent vector at the end points is same as that of the vector determined by first and last segments.      The convex hull property for a Bezier curve...