mirror of
https://github.com/PotentiaRobotics/ComputerVision.git
synced 2025-04-09 22:40:15 -04:00
27 lines
607 B
Python
27 lines
607 B
Python
import cv2 as cv
|
|
import numpy as np
|
|
|
|
img = cv.imread('Photos/cats.jpg')
|
|
cv.imshow('Cats', img)
|
|
|
|
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
|
|
cv.imshow('Gray', gray)
|
|
|
|
# Latplacian
|
|
lap = cv.Laplacian(gray, cv.CV_64F)
|
|
lap = np.uint8(np.absolute(lap))
|
|
cv.imshow('Latplacian', lap)
|
|
|
|
# Sobel
|
|
sobelx = cv.Sobel(gray, cv.CV_64F, 1, 0)
|
|
sobely = cv.Sobel(gray, cv.CV_64F, 0, 1)
|
|
combined_sobel = cv.bitwise_or(sobelx, sobely)
|
|
|
|
cv.imshow('Sobel X', sobelx)
|
|
cv.imshow('Sobel Y', sobely)
|
|
cv.imshow('Combined Sobel', combined_sobel)
|
|
|
|
canny = cv.Canny(gray, 150, 175) #uses Sobel
|
|
cv.imshow('Canny', canny)
|
|
|
|
cv.waitKey(0) |