#include <opencv2/opencv.hpp>
int main() {
// Read an image from file
cv::Mat image = cv::imread("path/to/your/image.jpg");
// Check if the image is loaded successfully
if (image.empty()) {
std::cerr << "Error: Unable to read the image." << std::endl;
return -1;
}
// Convert the image to grayscale
cv::Mat grayImage;
cv::cvtColor(image, grayImage, cv::COLOR_BGR2GRAY);
// Apply Gaussian blur to the grayscale image
cv::GaussianBlur(grayImage, grayImage, cv::Size(5, 5), 0);
// Use the Canny edge detector to detect edges in the image
cv::Mat edges;
cv::Canny(grayImage, edges, 50, 150);
// Display the original image
cv::imshow("Original Image", image);
// Display the grayscale image
cv::imshow("Grayscale Image", grayImage);
// Display the edges detected in the image
cv::imshow("Edges", edges);
// Wait for a key press and close the windows
cv::waitKey(0);
cv::destroyAllWindows();
return 0;
}