Files
Premik-ComfyUI-ImgPatchEditor/doc.md
T
2025-11-28 11:21:00 +01:00

3.2 KiB

Documentation Progress

nodes.py

  • ImgPatchNode: "A node for patching images by detecting differences and merging them. This node takes an original and an edited image, detects the changed areas, and merges the changes back into the original image. It provides several outputs for visualizing the process, including the final merged image, the mask used for merging, a heatmap of the differences, and a debug overlay."

image_warper.py

  • ScaleTranslationTransform: "A transformation that only considers uniform scaling and translation. This is a specialized version of SimilarityTransform that ignores rotation and shear."
  • ImageWarper: "Warps an edited image to align with an original image using feature matching. This class uses ORB feature detection and RANSAC to find a robust ScaleTranslationTransform. If alignment fails, it falls back to simple resizing."

patch_editor.py

  • PatchEditor: "Orchestrates the patch detection and merging process. This class acts as a high-level container for the patch editing workflow. It initializes the PatchDetector and PatchMerger, and provides a convenient factory method to be used from the ComfyUI node."

editor_ctx.py

  • EditorCtx: "A data class that holds the context and parameters for the patch editing process. This class encapsulates all the settings and images required for the patch detection and merging workflow."

patch_detector.py

  • PatchDetector: "Detects differences between two images and generates a heatmap of the changes. This class is responsible for comparing the original and edited images. It first aligns the images if allow_rescale is true, then uses a selected difference algorithm to calculate a heatmap of the changes."

patch_merger.py

  • PatchMerger: "Merges two images based on a detected patch, with various processing options. This class takes the heatmap from the PatchDetector and processes it to create a final mask. This mask is then used to composite the edited image onto the original image. It also provides methods for saving the merged image and debug artifacts."

diff_algs.py

  • DiffAlgorithm: "Base class for difference calculation algorithms. Subclasses should implement the calculate method to return a heatmap of differences between two images."
  • HeatmapDifference: "Calculates the difference between two images using ImageChops.difference. This is a simple and fast algorithm that computes the absolute difference for each pixel."
  • HeatmapL2Norm: "Calculates the L2 norm (Euclidean distance) between the pixel values of two images. This method is more sensitive to color variations than simple difference."
  • HeatmapSSIM: "Calculates the Structural Similarity Index (SSIM) between two images. SSIM is a perceptual metric that quantifies the similarity between two images, considering luminance, contrast, and structure."

test_transform.py

  • ScaleTranslationTransform: "A custom transformation model that only considers uniform scaling and translation. This class is a simplified version of skimage.transform.SimilarityTransform that ignores rotation and shear. It is used to estimate the transformation from a set of source and destination points."