"Lab Manual (Lab 4) ": "Artificial Intelligence"
"Lab Manual (Lab 4) ": "Artificial Intelligence"
“Artificial Intelligence”
Lab 04
Artificial Intelligence
Task 1
import cv2
image = cv2.imread(r"C:\Users\Hafsa\Desktop\A.jpg")
cv2.imshow('Original', image)
cv2.waitKey()
cv2.imshow('Grayscale', gray_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Output
Orginal
Gray Scale
Task 2
Convert image into four parts.
# -*- coding: utf-8 -*-
@author: Hafsa
"""
import math
import os
img = Image.open(image_path)
upper = 0
left = 0
slices = int(math.ceil(height/slice_size))
count = 1
#if we are at the end, set the lower bound to be the bottom of the image
if count == slices:
lower = height
else:
working_slice = img.crop(bbox)
upper += slice_size
count +=1
if __name__ == '__main__':
Output