#include <opencv2/opencv.hpp>
int main() {
// Read an RGB image from file
cv::Mat rgbImage = cv::imread("input_image.jpg");
// Check if the image is successfully loaded
if (rgbImage.empty()) {
std::cerr << "Error: Unable to read the image file." << std::endl;
return -1;
}
// Convert the RGB image to grayscale
cv::Mat grayImage;
cv::cvtColor(rgbImage, grayImage, cv::COLOR_RGB2GRAY);
// Display the original RGB image
cv::imshow("Original Image", rgbImage);
// Display the grayscale image
cv::imshow("Grayscale Image", grayImage);
// Wait for a key press and then close the windows
cv::waitKey(0);
cv::destroyAllWindows();
return 0;
}