from .ImageManipulation import ImageManipulation
from ImageContainer import ImageContainer
from typing import Any, List
from utils.image_utils import pil_to_cv2, cv2_to_pil
import cv2


class Grayscale(ImageManipulation):
    def getManipulationName(self) -> str:
        return "Grayscale"

    def getParameters(self) -> List[str]:
        return []

    def manipulateImage(self, image: ImageContainer, parameters: Any) -> None:
        if image is None or image.getImage() is None:
            return
        pil_img = image.getImage()
        cv_img = pil_to_cv2(pil_img)
        gray = cv2.cvtColor(cv_img, cv2.COLOR_BGR2GRAY)
        image._imageData = cv2_to_pil(gray)


