diff --git a/diff_algs.py b/diff_algs.py index af91ffd..7b49f45 100644 --- a/diff_algs.py +++ b/diff_algs.py @@ -18,11 +18,11 @@ class DiffAlgorithm: def calculate(self, img1: Image.Image, img2: Image.Image) -> np.ndarray: raise NotImplementedError - def get_threshold(self, sensibility: float) -> int: - if sensibility <= 1.0: - return int(self.half * sensibility) + def get_threshold(self, tolerance: float) -> int: + if tolerance <= 1.0: + return int(self.half * tolerance) else: - return int(self.half + (self.full - self.half) * (sensibility - 1.0)) + return int(self.half + (self.full - self.half) * (tolerance - 1.0)) @dataclass diff --git a/editor_ctx.py b/editor_ctx.py index 808370a..d4b0227 100644 --- a/editor_ctx.py +++ b/editor_ctx.py @@ -16,7 +16,7 @@ class EditorCtx: stride: int allow_rescale: bool min_area_size: int - sensibility: float + tolerance: float blur_radius: float mask_expansion: int edit_max_alpha: float @@ -24,4 +24,4 @@ class EditorCtx: edited_img_path: Optional[Path] = None def threshold(self, alg: "DiffAlgorithm") -> int: - return alg.get_threshold(self.sensibility) + return alg.get_threshold(self.tolerance) diff --git a/nodes.py b/nodes.py index d2fe8ec..d671872 100644 --- a/nodes.py +++ b/nodes.py @@ -24,12 +24,12 @@ class ImgPatchNode: }, ), "min_area_size": ("INT", {"default": 4, "min": 0, "max": 128, "tooltip": "Minimum size of the changed area to keep."}), - "sensibility": ( + "tolerance": ( "FLOAT", { "default": 0.5, "min": 0.0, - "max": 2.0, + "max": 5.0, "step": 0.01, "tooltip": "Sensitivity of difference detection. Higher values will detect more changes.", }, @@ -70,7 +70,7 @@ class ImgPatchNode: region_size: int, stride: int, min_area_size: int, - sensibility: float, + tolerance: float, blur_radius: float, mask_expansion: int, edit_max_alpha: float, @@ -103,7 +103,7 @@ class ImgPatchNode: region_size=region_size, stride=stride, min_area_size=min_area_size, - sensibility=sensibility, + tolerance=tolerance, blur_radius=blur_radius, mask_expansion=mask_expansion, edit_max_alpha=edit_max_alpha, diff --git a/patch_editor.py b/patch_editor.py index 20fbad4..ecbf72c 100644 --- a/patch_editor.py +++ b/patch_editor.py @@ -29,7 +29,7 @@ class PatchEditor: region_size: int, stride: int, min_area_size: int, - sensibility: float, + tolerance: float, blur_radius: float, mask_expansion: int, edit_max_alpha: float, @@ -47,7 +47,7 @@ class PatchEditor: stride=stride, allow_rescale=allow_rescale, min_area_size=min_area_size, - sensibility=sensibility, + tolerance=tolerance, blur_radius=blur_radius, mask_expansion=mask_expansion, edit_max_alpha=edit_max_alpha, @@ -72,7 +72,7 @@ def main() -> None: region_size=8, stride=1, min_area_size=4, - sensibility=0.5, + tolerance=0.5, blur_radius=3.0, mask_expansion=0, edit_max_alpha=1.0, diff --git a/patch_merger.py b/patch_merger.py index 1ae2211..3b3fc6e 100644 --- a/patch_merger.py +++ b/patch_merger.py @@ -20,7 +20,7 @@ class PatchMerger: @cached_property def raw_mask(self) -> Image.Image: heatmap = self.detector.heatmap - threshold = self.detector.detection_alg.get_threshold(self.ctx.sensibility) + threshold = self.detector.detection_alg.get_threshold(self.ctx.tolerance) # Apply threshold mask = heatmap.point(lambda p: 255 if p > threshold else 0)