File size: 508 Bytes
564df58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import numpy as np
from backend.annotators.control_interface import ControlInterface
from cv2 import Canny
from PIL import Image


class CannyControl(ControlInterface):
    def get_control_image(self, image: Image) -> Image:
        low_threshold = 100
        high_threshold = 200
        image = np.array(image)
        image = Canny(image, low_threshold, high_threshold)
        image = image[:, :, None]
        image = np.concatenate([image, image, image], axis=2)
        return Image.fromarray(image)