File size: 369 Bytes
a9d7745
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
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)