Professional Documents
Culture Documents
INTERNAL ASSESSMENT 1
SUBMITTED BY:
AGATHIYAN S
18352204
28/11/2020
1.GAUSSIAN BLUR:
img = cv2.imread('butterfly.jpg')
Output:
IMAGE CONTOURS:
im = cv2.imread('b.jpg')
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(imgray,127,255,0)
image, contours, hierarchy =
cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
Code:
COLOR IMAGES:
import cv2
image = cv2.imread("butterfly.jpg")
(or)
image = cv2.imread("butterfly.jpg", cv2.IMREAD_GRAYSCALE)
gaussian_3 = cv2.GaussianBlur(image, (0, 0), 2.0)
unsharp_image = cv2.addWeighted(image, 1.5, gaussian_3, -0.5, 0,
image)
sub = cv2.subtract(gaussian_3, unsharp_image)
cv2.imshow('Original', gaussian_3)
cv2.imshow('UnSharp', unsharp_image)
cv2.imshow('Subtract', sub)
cv2.waitKey(0)
cv2.destroyAllWindows()
Output:
Output:
GRAYSCALE IMAGES
3. IMAGE GRADIENTS:
An image gradient is a directional change in the intensity or
colour in an image. The gradient of the image is one of the
fundamental building blocks in image processing.
For example, the Canny edge detector uses image gradient
for edge detection.
EDGE DETECTION:
Syntax:
Syntax:
Code:
import cv2
import numpy as np
from matplotlib import pyplot as plt
image = cv2.imread("S.jpg",cv2.IMREAD_GRAYSCALE)
lap = np.uint8(np.absolute((lap)))
sobelX = np.uint8(np.absolute((sobelX)))
sobelY = np.uint8(np.absolute((sobelY)))
for i in range(5):
plt.subplot(2, 3, i+1),plt.imshow(images[i], 'gray')
plt.title(titles[i])
plt.xticks([]),plt.yticks([])
plt.show()
Output: