img = cv2.imread(fname, cv2.IMREAD_UNCHANGED)height, width = img.shape hist_data = img.flatten() fig = plt.figure(figsize = (20, 10)) ax1 = fig.add_subplot(1, 2, 1) ax1.imshow(img, 'gray')ax1.set_xticks()ax1.set_yticks() # to hide tick values on X and Y axis ax2 = fig.add_subplot(1, 2, 2) ax2.hist(h…