#include <opencv2/opencv.hpp>
int main() {
// Read an image from file
cv::Mat image = cv::imread("input_image.jpg", cv::IMREAD_GRAYSCALE);
// Check if the image is successfully loaded
if (image.empty()) {
return -1;
}
// Set a threshold value (127 in this case)
int thresholdValue = 127;
// Apply binary thresholding to the image
cv::Mat binaryImage;
cv::threshold(image, binaryImage, thresholdValue, 255, cv::THRESH_BINARY);
// Display the original and binary thresholded images
cv::imshow("Original Image", image);
cv::imshow("Binary Threshold Image", binaryImage);
cv::waitKey(0);
return 0;
}