Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

EXPERIMENT - 1

Objective:
To read image, display image and perform algebraic operations addition, multiplication
and subtraction.

Introduction:
The aim of this experiment is to explore basic image processing techniques using the
OpenCV library in Python. The primary objectives include reading an image, displaying it,
and performing simple algebraic operations to manipulate the pixel values.

Materials and Setup:


Python installed on your system
OpenCV library installed (pip install open cv-python)
Sample image file for testing

Code and Methodology:


import cv2
import numpy as np
# To read image from disk, we use
# cv2.imread function, in below method,
img1 = cv2.imread("download.jpeg", cv2.IMREAD_COLOR)
img2 = cv2.imread("images.jpeg", cv2.IMREAD_COLOR)

cv2.imshow("image", img1)
cv2.imshow("image",img2)

a = cv2.resize(img2,(400,400))
b= cv2.resize(img1,(400,400))
add= cv2.add(a,b)
mull = cv2.multiply(a,b)
sub = cv2.subtract(a,b)
div = cv2.divide(b,a)

cv2.imshow("image",add)

cv2.waitKey(0)

Result:
The original image was successfully read and displayed. Algebraic operations (addition,
multiplication, subtraction) were performed on the image, resulting in modified images with
adjusted pixel values.

You might also like