Professional Documents
Culture Documents
Programs_8,11,12
Programs_8,11,12
import cv2
import numpy as np
return translated_image
image = cv2.imread('sample.png')
h = int(input("How many pixels you want the image to be translated horizontally? "))
v = int(input("How many pixels you want the image to be translated vertically? "))
cv2.imwrite('Final_image.png', translated_image)
INPUT:
OUTPUT:
import cv2
import numpy as np
image_path = 'sample.png'
image = cv2.imread(image_path)
# Apply thresholding (you can use other techniques like Sobel edges)
# Find contours
cv2.imshow('Contours', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
INPUT:
OUTPUT:
import cv2
image_path = 'faces.jpg'
image = cv2.imread(image_path)
cv2.waitKey(0)
cv2.destroyAllWindows()
INPUT:
OUTPUT: