# apply binary thresholding ret, thresh = cv2.threshold(img_gray, 150, 255, cv2.THRESH_BINARY) # visualize the binary image cv2.imshow('Binary image', thresh) cv2.waitKey(0) cv2.imwrite('image_thres1.jpg', thresh) cv2.destroyAllWindows(). C++
import cv2 import numpy as np import matplotlib.pyplot as plt. After importing the libraries, we can plot the original image, so we know what's changing. image = cv2.imread('Images/6.jpg') image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)fig, ax = plt.subplots(1, figsize=(12,8)) plt.imshow(image).