Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Filter.py
- import matplotlib.pyplot as plt
- from skimage import data, filters
- image = data.coins()
- edges = filters.sobel(image)
- plt.imshow(edges, cmap='gray')
- plt.show()
- FilterCanny.py
- import numpy as np
- import cv2
- img = cv2.imread('peter.jpg')
- t_lower = 50
- t_upper = 100
- apenture_size= 5
- edge = cv2.Canny(img,t_lower,t_upper,apenture_size)
- cv2.imshow('Original image',img)
- cv2.imshow('Edge image',edge)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
- Prewitt / Robert is Homework
- import numpy as np
- import cv2
- from skimage.filters import prewitt, roberts
- from skimage import io, color
- # Load the image
- img = cv2.imread('peter.png')
- # Convert the image to grayscale (Prewitt and Roberts work on grayscale)
- gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
- # Perform Prewitt edge detection
- prewitt_edges = prewitt(gray_img)
- # Perform Roberts edge detection
- roberts_edges = roberts(gray_img)
- # Display the results
- cv2.imshow('Original Image', gray_img)
- cv2.imshow('Prewitt Edge Detection', prewitt_edges)
- cv2.imshow('Roberts Edge Detection', roberts_edges)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement