guo3 / utils.py
guohp123456's picture
Create utils.py
a9d7745 verified
raw
history blame contribute delete
369 Bytes
import cv2
import numpy as np
from PIL import Image
def generate_canny(image: Image.Image, low_threshold=50, high_threshold=150) -> Image.Image:
image = image.resize((1024, 1024))
img_np = np.array(image)
edges = cv2.Canny(img_np, low_threshold, high_threshold)
edges_rgb = cv2.cvtColor(edges, cv2.COLOR_GRAY2RGB)
return Image.fromarray(edges_rgb)