Last active
January 30, 2019 05:40
-
-
Save hkhojasteh/27da434736e4f4a26610edf1f1e4a791 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mat detected_edges, img_mask; | |
int const max_lowThreshold = 255; | |
int lowThreshold = 210, ratio = 3, kernel_size = 3; | |
char* window_name = "Edge Map"; | |
//CannyThreshold: Trackbar callback - Canny thresholds input with a ratio 1:3 | |
void CannyThreshold(int, void*){ | |
blur(img_mask, detected_edges, Size(3, 3)); //Reduce noise with a kernel 3x3 | |
Canny(detected_edges, detected_edges, lowThreshold, lowThreshold * ratio, kernel_size); //Canny detector | |
imshow(window_name, detected_edges); //Using Canny's output as a mask, and display our result | |
} | |
detected_edges.create(img_mask.size(), img_mask.type()); //Create a window | |
namedWindow(window_name); | |
createTrackbar("Min Threshold:", window_name, &lowThreshold, max_lowThreshold, CannyThreshold); // Create a Trackbar for user to enter threshold | |
CannyThreshold(0, 0); //Show the image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment