A collection of custom nodes for ComfyUI focused on luminosity masks, image processing, upscaling, and dynamic code hot-reloading.
-
Clone this repository into your
ComfyUI/custom_nodes/directory:cd ComfyUI/custom_nodes git clone https://github.com/Maelstrom2014/Comfyui-Luminocity-masks.git -
Install the required Python dependencies:
pip install opencv-python scipy matplotlib scikit-image
-
Restart ComfyUI.
Create and manipulate luminosity-based masks for precise image editing. Based on the Luminocity workflow with LAB color space processing.
Use cases:
- Basic lightness balancing (darken lights, brighten shadows)
- Create mood with dark midtones
- Improved vignetting with midtone masks
- Fix overexposed highlights and inpaint with SD models
- Separate detail extraction from darks, mids, and highlights
- Portraits: adjust contrast per channel (more contrast = more skin/wrinkles, less = younger skin)
- Classic color balancing: cool tones in shadows, warm tones in highlights
Nodes:
- LuminocityMaskCreate (
LumMasks) - Create luminosity masks from images - LumMaskColorCorrect (
LumColorCorrect) - Apply color correction using luminosity masks - LumBlendImages (
BlendMasked) - Blend images using luminosity masks as alpha - LumImageColorMatch (
LumImageColorMatch) - Match colors between images using LAB color space
Nodes:
- Upscale Image (Torch Compile) (
UpscaleWithTorchCompile) - Memory-efficient upscaling using PyTorch's compile feature with tiled processing
Features:
- Torch compile support (
reduce-overheadormax-autotunemodes) - Tiled upscaling (512px tiles, 32px overlap) for memory efficiency
- Compiled model caching for repeated use
Nodes:
- Smart Saturation (
SmartSaturation) - Intelligent saturation adjustment using LAB color space
Nodes:
- Maelstrom Dynamic Tool #1 (
MaelstromDynamicTool1) - Dynamic processing with code hot-reload capability. Edit behavior code without restarting ComfyUI - Delete Empty Image From Batch (
DeleteEmptyImageFromBatch) - Remove all-zero tensors from image batches - Delete Empty Mask From Batch (
DeleteEmptyMaskFromBatch) - Remove all-zero tensors from mask batches
Nodes:
- Resize to Square with fill - Resize images to square format with configurable fill
maelstrom_tools/
├── __init__.py # Main entry point - dynamically loads all node modules
├── maelstrom_nodes.py # Dynamic tools, batch cleaners (hot-reload system)
├── lum_masks_node.py # Luminosity mask creation, color correction, blending
├── smart_saturation.py # Smart saturation adjustment
├── tc_upscale.py # Torch compile upscaler
├── gaus_func.py # Gaussian function utilities
├── labtools.py # LAB color space conversion and manipulation
├── Animals.py # Bobr class - function pointer pattern for dynamic code
├── behaviors/
│ ├── BobrBehaviors.py # Dynamic behavior implementations (hot-reloadable)
│ └── test_pytorch.py # PyTorch test utilities
├── Smetana/ # Alternative/legacy implementations
│ ├── Animals.py
│ ├── BobrBehaviors.py
│ ├── CustomNode.py
│ └── FunctionPointerDemo.py
├── examples/ # Example workflows and images
│ ├── lum_masks_example1.json
│ └── lum_masks_example1.png
├── workflow (7).png # Workflow screenshots
└── workflow (8).png
- PyTorch (comes with ComfyUI)
- OpenCV (
opencv-python) - SciPy
- NumPy
- Pillow (PIL)
- scikit-image
- Matplotlib
All nodes appear under the "MaelstromTools" or "image/upscaling" categories in the ComfyUI node menu.
The dynamic tools use a function pointer pattern (Animals.py / behaviors/BobrBehaviors.py) that allows code to be reloaded at runtime:
- The
Bobrclass holds a function pointer (the_actual_code_of_the_kurva_function) - Behavior functions in
BobrBehaviors.pycan be reloaded viaimp.reload() - Changes to behavior code take effect immediately without restarting ComfyUI
Luminosity masks work by:
- Converting images to LAB color space (
labtools.py) - Extracting the Lightness (L) channel
- Creating smooth masks using Gaussian/spline interpolation
- Applying targeted adjustments to shadows, midtones, or highlights independently
See the examples/ folder for sample workflows:
lum_masks_example1.json- Luminosity mask workflow with all presetslum_masks_example1.png- Example output
Pull requests welcome! Please ensure all nodes follow ComfyUI's node format conventions.