You are on page 1of 6

18VAC10-IMAGE AND VIDEO PROCESSING USING

PYTHON
LAB END SEMESTER EXAM

STUDENT NAME: SUBASHNANDHAN J

STUDENT ROLLNO: 19CHR088


QUESTION

Read an image, take 2 Region of Interest(ex. If image is of size 640, 640


take (0:320, 0:320, 320:640,
320:640)) and perform the following operation
a. On first ROI perform HSV color conversion
b. On second ROI perform gray scale conversion
c. Display the combined output
IMPLEMENTATION CODING
Coding:
from google.colab.patches import cv2_imshow
import cv2
image = cv2.imread("/content/mustang-6578976.jpg")
rows, cols, channel = image.shape

#On first ROI perform HSV color conversion


roi1 = image[int(rows//2):, int(cols//2):]
roi1_color = cv2.cvtColor(roi1, cv2.COLOR_BGR2HSV)
IMPLEMENTATION CODING
⮚ Coding
#On second ROI perform gray scale conversion
roi2 = image[0: int(rows//2),0: int(cols//2)]
roi2_color = cv2.cvtColor(roi2, cv2.COLOR_BGR2GRAY)
roi2_color = cv2.merge((roi2_color, roi2_color, roi2_color))

image[0: int(rows//2),0: int(cols//2)] = roi2_color


image[int(rows//2):, int(cols//2):] = roi1_color
#Display the combined output
cv2_imshow(image)
INPUT
OUTPUT

You might also like