Lab No. 5 Ippr
Lab No. 5 Ippr
5
TITLE:- IMAGE TRANSFORMATION USING OPENCV.
OBJECTIVE:-
➢ To understand and implement about image transformations techniques
such as translation, rotation, flipping, and resizing.
THEORY:-
Image transformation is a key concept in image processing that modifies the spatial
relationship of pixels in an image. It includes several basic operations:
• Translation moves the image from one position to another along the x and
y axes, useful for shifting objects within a frame.
• Rotation turns the image around a fixed point, typically the center, and is
used for orientation adjustments.
• Resizing changes the width and height of the image, which is important for
standardizing input sizes in machine learning or display purposes.
These transformations help in preparing images for analysis, improving model
performance, and enhancing visual interpretation.
SOURCE CODE:-
import cv2 as cv
import numpy as np
img=cv.imread('Photos/Flower.jpg')
cv.imshow('Flower',img)
#Translation
def translate(img,x,y):
transMat=np.float32([[1,0,x],[0,1,y]])
dimensions=(img.shape[1], img.shape[0])
return cv.warpAffine(img,transMat,dimensions)
# -x --> Left
# -y --> Up
# x --> Right
# y --> Down
CONCLUSION:-
In this lab, we learned how to apply basic image transformation techniques such as
translation, rotation, flipping, and resizing. These operations are fundamental in
image processing and are useful for preparing and augmenting images in various
real-world applications, especially in computer vision tasks.