Files
Premik-ComfyUI-ImgPatchEditor/editor_ctx.py
T
2025-11-28 11:08:51 +01:00

28 lines
665 B
Python

from PIL import Image
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Optional
if TYPE_CHECKING:
from .diff_algs import DiffAlgorithm
@dataclass
class EditorCtx:
original_img: Image.Image
edited_img: Image.Image
detection_alg: str
region_size: int
stride: int
allow_rescale: bool
min_area_size: int
tolerance: float
blur_radius: float
mask_expansion: int
edit_max_alpha: float
original_img_path: Optional[Path] = None
edited_img_path: Optional[Path] = None
def threshold(self, alg: "DiffAlgorithm") -> int:
return alg.get_threshold(self.tolerance)