Display the edge detection resultscv imshow edges
Edge detection Assignment Answers
Question:
In python, Using OpenCV, generate a synthetic image that contains exactly one filled-in square and one filled-in circle. The placement and color intensities of these shapes are up to you. The background intensity is up to you as well. You should know precisely the locations of the discontinuities. The rest of the image should be without edges.
Edge detection Answer and Explanation
import cv2
# Generate a blank image
# Draw a filled square (blue color)
square_size = 100
circle_radius = 50
circle_color = 100
cv2.waitKey(0)
cv2.destroyAllWindows()
edges_canny = cv2.Canny(gray, 50, 150)
# Apply Sobel edge detection
edges_laplacian = cv2.Laplacian(gray, cv2.CV_64F)
# Display the edge detection results
cv2.destroyAllWindows()
Step 3: Evaluate Performance
mean = 0
variance = 0.1
sobel_x_noisy = cv2.Sobel(noisy_image, cv2.CV_64F, 1, 0, ksize=5)
sobel_y_noisy = cv2.Sobel(noisy_image, cv2.CV_64F, 0, 1, ksize=5)
You can change the threshold values for Canny edge detection and adjust Sobel and Laplacian parameters to optimize edge detection performance.
Evaluation