Matlib Image

mail@pastecode.io avatar
unknown
plain_text
2 months ago
621 B
3
Indexable
Never
import cv2
import matplotlib.pyplot as plt
import os

image_path = r'D:\Superhero\Script\python\matlab\download.jpg'

if not os.path.isfile(image_path):
    print("Image file does not exist at the specified path:", image_path)
    exit()

img = cv2.imread(image_path)

if img is None:
    print("Unable to read the image at the specified path:", image_path)
    exit()

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

edges = cv2.Canny(gray, 100, 200)

plt.figure()
plt.title('download')
plt.imsave('download-result.png', edges, cmap='gray', format='png')
plt.imshow(edges, cmap='gray')
plt.show()
Leave a Comment