ComfyUI Extension: Easy Color Correction

Authored by regiellis

Created

Updated

78 stars

ComfyUI custom node for flexible and efficient image color correction and post-processing.

Custom Nodes (0)

    README

    ComfyUI-EasyColorCorrector ๐ŸŽจ

    Professional-grade AI-powered color correction and enhancement for ComfyUI

    License: MIT Python 3.8+ ComfyUI

    [!WARNING] Release v1.2.1 introduces major refactoring and enhancements and a need name change to ComfyUI-EasyColorCorrector. This is a breaking change and you will may need to uninstall the old node before installing the new one.

    [!NOTE] Disclaimer: I'm obviously joking about the "$1000+ plugin" claims and competing with Photoshop - this is a ComfyUI custom node, not industry software! ๐Ÿ˜„ BUT it does have legit AI-powered features, face detection, and professional color science. And hey, it beats paying Adobe! ๐Ÿ’ฐ


    ๐Ÿ†• Latest Updates (Major Update)

    โœจ Major Professional Improvements & Fixes

    • Manual Mode is now truly professional: Real temperature + tint separation (LAB color space), not just hue sliders
    • Preset Mode is transparent: Sliders update live to show exactly what each preset does
    • Slider ranges are realistic: No more wild valuesโ€”contrast/brightness are now in sensible ranges
    • White Balance is professional: -1.0 (cool/blue) to +1.0 (warm/orange), like real color grading software
    • Skin tone processing fixed: No more green tint on light skinโ€”portraits look natural
    • Smart UI: AI analysis auto-disables in Manual mode for pure manual control
    • Live Preset Updates: See exactly what each preset does to your sliders
    • 2-Axis Color Control: Separate temperature and tint like the pros use
    • Working 3-Way Correction: Lift/Gamma/Gain actually works now

    ๐Ÿ†• New Nodes

    • VAE Color Corrector: Fix VAE-induced color shifts in inpainting/img2img workflows with advanced bias analysis
    • Batch Color Corrector: Process entire video sequences with the same AI-powered corrections
    • RAW Image Processor: Direct RAW file processing with professional color science
    • Color Corrector Viewer: Real-time preview and analysis for video workflows
    • Color Palette Extractor: Standalone palette extraction for reference workflows
    • Film Emulation: Professional film stock emulation with highlight rolloff

    The main Color Corrector is professional-grade and rock solid. The specialized nodes target specific workflows and advanced use cases.


    ๐Ÿš€ What is this?

    ComfyUI-EasyColorCorrector is a professional-grade, AI-powered color correction suite that democratizes advanced color grading for the ComfyUI ecosystem.

    Thatโ€™s the fancy version.

    Real talk: Iโ€™m not trying to take over the color correction world. Itโ€™s just a node.

    I built it to bridge the gap between โ€œAI, do the thingโ€ and โ€œlet me tweak this like Iโ€™m grading a Netflix series.โ€ If it helps artists, creators, and chaos-powered ComfyUI users get better color without paying Adobe or wiring 12 nodes together? Mission accomplished.

    If notโ€ฆ hey, at least now you have histograms.

    This node is opinionated about color science - it leverages computer vision, perceptual color spaces, and advanced algorithms to deliver results that rival industry-standard color grading tools.

    ๐Ÿคฏ The TL;DR

    • ๐Ÿค– AI-Powered: Face detection, scene analysis, content-aware enhancement
    • ๐ŸŽจ Professional: LAB color space, 3-way color correction, perceptual curves
    • โšก Real-time: Selective node execution for instant feedback
    • ๐ŸŽ›๏ธ Three Modes: Auto (AI magic), Preset (curated looks), Manual (full control)

    alt text

    โœจ Key Features

    ๐Ÿค– AI-Powered Intelligence

    • Face Detection: Automatic skin tone preservation using OpenCV with advanced segmentation
    • Advanced Scene Analysis: Detects anime, concept art, stylized art, detailed illustrations, portraits, and realistic photos
    • Lighting Detection: Low-light, bright, flat, optimal lighting analysis
    • Content-Aware Enhancement: Specialized profiles for artistic content vs. photographic content
    • Edge-Aware Processing: Multi-scale edge detection with detail preservation
    • Advanced Segmentation: SLIC-based skin region detection for precise face enhancement

    ๐ŸŽจ Professional Color Science

    • LAB Color Space: Perceptual white balance and color corrections with Bradford chromatic adaptation
    • K-means Analysis: Intelligent dominant color extraction in both RGB and LAB spaces
    • 3-Way Color Corrector: Professional lift/gamma/gain controls
    • Perceptual Curves: Gamma-aware brightness and contrast
    • Advanced Color Matching: Robust reference image color matching with histogram and LAB methods
    • Professional Color Extraction: Brightness-sorted palette generation with perceptual spacing

    โšก Performance & Usability

    • Real-time Preview: Selective node execution (no full workflow runs)
    • Graceful Fallbacks: Works without advanced libraries installed
    • Three Distinct Modes: Each optimized for different use cases
    • Smart UI: Mode-specific controls with intelligent tooltips
    • Visual Outputs: Built-in histogram and color palette image generation
    • Multiple Output Types: Processed image, palette data, histogram image, and palette image

    ๐ŸŽ›๏ธ The Three Modes

    ๐Ÿค– Auto Mode: AI Magic

    Just make it look amazing

    The AI analyzes your image and applies:

    • Scene-specific enhancement profiles for 6 content types (anime, concept art, stylized art, detailed illustrations, portraits, realistic photos)
    • Intelligent white balance in LAB color space
    • Face-aware skin tone preservation using OpenCV detection
    • Adaptive contrast and saturation with up to 50% boost for concept art
    • Lighting-aware brightness adjustments for low-light, bright, flat, and optimal conditions
    • Enhanced glow effects for artistic content with stronger highlight enhancement

    Perfect for: Quick enhancement, artistic content, concept art, anime, batch processing

    ๐ŸŽจ Preset Mode: Curated Looks

    Give me that specific vibe

    30 professional presets with intelligent slider updates:

    Portrait Presets (5): Natural, Warm, Cool, High Key, Dramatic
    Concept Art & Illustration (6): Epic Fantasy, Sci-Fi Chrome, Dark Fantasy, Vibrant Concept, Matte Painting, Digital Art
    Artistic & Stylized (6): Anime Bright, Anime Moody, Cyberpunk, Pastel Dreams, Neon Nights, Comic Book
    Cinematic (5): Cinematic, Teal & Orange, Film Noir, Vintage Film, Bleach Bypass
    Natural (4): Golden Hour, Blue Hour, Sunny Day, Overcast
    Classic (4): Sepia, Black & White, Faded, Moody

    Enhanced Features:

    • Live slider updates: Presets automatically update parameter sliders for full transparency
    • Content-aware adaptation: Presets automatically adjust based on detected scene type
    • Artistic content boost: Up to 40% enhancement for concept art and illustrations
    • Smart variation: Intelligent randomization that respects the original artistic intent

    Perfect for: Consistent styling, concept art workflows, artistic looks, client work

    ๐ŸŽ›๏ธ Manual Mode: Professional Control

    "I know exactly what I want"

    Professional-grade tools with pure manual control:

    • Professional Temperature & Tint: Separate LAB color space controls (blueโ†”orange, greenโ†”magenta)
    • 3-way color corrector: Lift/Gamma/Gain with balanced ranges for precise control
    • Intelligent UI: AI analysis auto-disabled for pure manual workflow
    • Balanced parameter ranges: Realistic slider ranges that don't break at low values
    • Professional color grading: Works like Lightroom/DaVinci Resolve
    • Film-like grain with luminance preservation
    • Enhanced sliders: Fine-tuned steps for precise adjustments

    Perfect for: Precision work, professional color grading, learning, complex corrections


    ๐Ÿ”ง VAE Color Corrector

    Fix VAE-Induced Color Shifts in Inpainting Workflows

    A specialized node designed to solve a common ComfyUI problem: when images go through VAE encoding/decoding (especially in inpainting workflows), they often develop noticeable color shifts compared to the original input.

    โœจ Key Features

    • Four Correction Methods:

      • Luminance Zones: Professional shadows/midtones/highlights correction (recommended)
      • Histogram Matching: Match color distributions between original and processed
      • Statistical Matching: Align color statistics (mean/std) across channels
      • Advanced 3D LUT: Precise 3D color mapping using k-means clustering
    • VAE-Aware Analysis:

      • Analyzes color bias patterns across luminance zones
      • Detects high/medium/low VAE color bias automatically
      • Applies intelligent strength adjustments based on bias severity
    • Smart Preservation:

      • Auto-detect: Automatically identifies and preserves inpainted areas
      • Mask-based: Use custom masks (white=preserve, black=correct)
      • Edge feathering: Smooth transitions between corrected/preserved areas
    • Performance Features:

      • Lock Input: Prevents upstream reprocessing when adjusting parameters
      • Smart Caching: Preserves expensive VAE analysis between adjustments
      • Safe Color Clamping: Prevents quantization artifacts (black squares)

    ๐ŸŽฏ Perfect For

    • Inpainting workflows where color shifts occur after VAE processing
    • Img2img workflows with noticeable color deviations
    • Batch processing with consistent VAE color correction
    • Professional workflows requiring precise color matching

    ๐Ÿš€ Usage

    1. Connect original image (before VAE encoding)
    2. Connect processed image (after VAE decoding)
    3. Choose correction method (start with "luminance_zones")
    4. Adjust correction strength (0.8 is usually good)
    5. Enable lock_input_image for real-time parameter tuning
    Original Image โ†’ VAE Encode โ†’ [Inpainting/Processing] โ†’ VAE Decode โ†’ Processed Image
         โ†“                                                                    โ†“
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ VAE Color Corrector โ†โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                        โ†“
                                Color-Corrected Result
    

    ๐Ÿ“Š Visual Outputs & Analysis

    ๐Ÿ–ผ๏ธ Four Output Types

    The node provides four distinct outputs for maximum workflow flexibility:

    1. ๐Ÿ“ธ Processed Image: Your enhanced/corrected image
    2. ๐ŸŽจ Palette Data: Comma-separated hex color string for other nodes
    3. ๐Ÿ“Š Histogram Image: RGB histogram visualization (512ร—768px)
    4. ๐ŸŽจ Palette Image: Clean color swatches visualization (600ร—120px)

    ๐Ÿ“ˆ Histogram Visualization

    • Professional RGB histogram with proper scaling and contrast
    • Multi-channel overlay showing red, green, and blue distributions
    • Dark background with subtle grid lines for better readability
    • Connect to Preview Image node to view during processing

    ๐ŸŒˆ Color Palette Extraction

    • 6 dominant colors extracted using advanced K-means clustering
    • Perceptual LAB-space analysis for better color representation
    • Brightness-sorted arrangement for natural palette flow
    • Clean swatch design without borders or text clutter
    • Connect to Preview Image node for instant palette viewing

    ๐Ÿ”ง Reference Image Color Matching

    • Robust histogram matching prevents black spots and artifacts
    • Conservative LAB adjustments for natural color transitions
    • Multi-method approach with safe fallbacks
    • Strength control from 0.0 (no effect) to 1.0 (full matching)

    ๐Ÿ› ๏ธ Installation

    Quick Install (Recommended)

    cd ComfyUI/custom_nodes
    git clone https://github.com/regiellis/ComfyUI-EasyColorCorrector.git
    cd ComfyUI-EasyColorCorrector
    pip install -r requirements.txt
    

    Manual Install

    1. Download and extract to ComfyUI/custom_nodes/ComfyUI-EasyColorCorrector
    2. Install dependencies:
    pip install \
        "torch>=1.12.0" \
        "numpy>=1.21.0" \
        "opencv-python>=4.8.0" \
        "scikit-learn>=1.3.0" \
        "scikit-image>=0.21.0" \
        "colour-science>=0.4.3" \
        "scipy>=1.11.0" \
        "rawpy>=0.18.0" \
        "imageio>=2.28.0" \
        "OpenEXR>=1.3.9" \
        "Pillow>=9.0.0" \
        "torchvision>=0.13.0" \
        "huggingface_hub>=0.15.0" \
        "timm>=0.9.2"
    
    1. Restart ComfyUI

    Note: The node works without the advanced libraries, but you'll miss the AI-powered features. Install them for the full experience!


    ๐ŸŽฎ Usage

    Basic Workflow

    Main Color Corrector

    1. Add "Easy Color Corrector" node to your workflow
    2. Connect an image input
    3. Choose your mode:
      • Auto: Enable AI analysis and let it work its magic
      • Preset: Pick a style and optionally enable AI adaptation
      • Manual: Full control with professional tools
    4. Connect outputs as needed:
      • Main image output โ†’ Save Image or further processing
      • Histogram output โ†’ Preview Image (to see RGB analysis)
      • Palette output โ†’ Preview Image (to see color swatches)
      • Palette data โ†’ Text nodes or other color-aware nodes

    VAE Color Corrector

    1. Add "VAE Color Corrector" node to your workflow
    2. Connect original image (before VAE) and processed image (after VAE)
    3. Choose correction method (start with "luminance_zones")
    4. Adjust correction strength (0.8 recommended)
    5. Optionally provide a mask or enable auto-preserve for inpainted areas

    ๐Ÿ“Š Enabling Visual Analysis

    Enable "Extract Palette" to generate:

    • โœ… RGB histogram visualization
    • โœ… Color palette extraction and visualization
    • โœ… Dominant color analysis in the console
    • โœ… Advanced K-means clustering

    When disabled, histogram and palette outputs will be black images.

    ๐Ÿ”ฅ Pro Tips

    • Enable Real-time Preview for instant feedback (uses selective execution)
    • Manual Mode auto-disables AI for pure manual control (can re-enable if needed)
    • Preset sliders update automatically showing exactly what the preset does
    • White Balance: -1.0 = cooler/blue, +1.0 = warmer/orange (professional range)
    • Temperature & Tint: Separate controls in Manual mode for professional color grading
    • Face detection works best with clear, well-lit portraits
    • Try presets first, then fine-tune with manual controls
    • Enable Extract Palette to see histogram and color analysis
    • Use Reference Image for mood board color matching
    • Connect histogram/palette outputs to Preview Image nodes for visual feedback

    Example Console Output

    ๐Ÿค– AI Analysis: concept_art scene, good lighting, 0 faces detected
    ๐ŸŽจ AI-Enhanced Preset: Epic Fantasy adapted for concept_art/good
    ๐ŸŽ›๏ธ Manual Mode: Auto-disabled AI analysis for pure manual control
    ๐ŸŒก๏ธ Applied professional color adjustments: temperature: 0.3 (warmer), tint: -0.1 (green)
    ๐ŸŽจ Extracted color palette: #2A1810,#8B4513,#D2691E,#F4A460,#DEB887,#F5DEB3
    ๐Ÿ–ผ๏ธ Histogram and palette images available as separate node outputs
    

    โš™๏ธ Advanced Configuration

    AI Analysis Control

    ai_analysis: bool = True          # Enable AI-powered features
    adjust_for_skin_tone: bool = True # Face detection + skin preservation  
    white_balance_strength: 0.0       # Temperature: -1.0 (cool) to +1.0 (warm)
    enhancement_strength: 0.2         # Overall AI enhancement power (balanced default)
    extract_palette: bool = False     # Generate histogram and palette images
    

    Lock Input Image

    lock_input_image: bool = False    # Lock input to prevent upstream reprocessing
    # When enabled: Caches input image so upstream nodes don't reprocess
    # Result: Faster parameter adjustments without full workflow regeneration
    

    Performance Modes

    • Full AI: All features enabled (default)
    • Basic Mode: AI analysis disabled for maximum speed
    • Real-time: Selective execution for instant feedback

    ๐Ÿง  The Science Behind It

    Computer Vision Pipeline

    1. OpenCV Face Detection: Haar cascade classifiers with SLIC segmentation
    2. K-means Color Analysis: 5-cluster dominant color extraction in RGB and LAB spaces
    3. Edge Density Analysis: Multi-scale edge detection for anime vs. photo classification
    4. Histogram Analysis: Lighting condition detection and RGB distribution analysis
    5. Advanced Segmentation: SLIC superpixel segmentation for precise skin tone detection

    Color Science

    1. LAB Color Space: Perceptual uniformity for white balance with Bradford chromatic adaptation
    2. Perceptual Curves: Gamma-aware brightness/contrast with edge preservation
    3. Selective Saturation: Vibrancy that preserves skin tones using advanced masking
    4. 3-Way Correction: Professional lift/gamma/gain masking with artistic content awareness
    5. Advanced Color Matching: Histogram-based and LAB color space reference matching
    6. Professional Palette Extraction: Brightness-sorted dominant colors with perceptual spacing

    AI Enhancement Profiles

    if scene_type == "concept_art":
        contrast_boost = 0.35 * enhancement_strength
        saturation_boost = 0.5 * enhancement_strength
    elif scene_type == "anime":
        contrast_boost = 0.25 * enhancement_strength
        saturation_boost = 0.45 * enhancement_strength
    elif scene_type == "portrait":
        # More conservative for faces
        contrast_boost = 0.15 * enhancement_strength
        # + automatic skin warmth boost
    

    ๐Ÿค Contributing

    Found a bug? Have an idea? Want to add more presets?

    1. Fork the repository
    2. Create a feature branch (git checkout -b amazing-feature)
    3. Commit your changes (git commit -m 'Add amazing feature')
    4. Push to the branch (git push origin amazing-feature)
    5. Open a Pull Request

    ๐ŸŽจ Adding New Presets

    "Your Preset Name": {
        "warmth": 0.1,      # -1.0 to 1.0
        "vibrancy": 0.3,    # -1.0 to 1.0  
        "contrast": 0.2,    # -1.0 to 1.0
        "brightness": 0.05  # -1.0 to 1.0
    }
    

    ๐Ÿ“ License

    This project is licensed under the MIT License - see the LICENSE file for details.


    ๐Ÿ™ Acknowledgments

    • ComfyUI Community for the amazing framework
    • OpenCV for computer vision capabilities
    • Colour Science for professional color space operations
    • scikit-learn for machine learning algorithms

    ๐Ÿ’ก FAQ

    Q: Do I need all the dependencies?
    A: The node works without them, but you'll miss the AI features. Install them for the full experience!

    Q: Is this better than Photoshop?
    A: For color correction? It's competitive. For everything else? No. ๐Ÿ˜„

    Q: Can I use this commercially?
    A: Yes! MIT license means you can use it however you want.

    Q: Why is it called "Easy" when it's so advanced?
    A: Because the AI makes professional color grading easy. The complexity is hidden behind intelligent automation.

    Q: What's the difference between the main node and VAE Color Corrector?
    A: The main node is for general color correction and enhancement. VAE Color Corrector specifically fixes color shifts that occur when images go through VAE encoding/decoding in ComfyUI workflows.

    Q: When should I use the VAE Color Corrector?
    A: Use it when you notice color shifts after inpainting, img2img, or any workflow where images pass through a VAE. Connect the original (pre-VAE) and processed (post-VAE) images.

    Q: Why am I getting black squares in my images?
    A: This was a quantization artifact issue that's now fixed with safe color clamping. Update to the latest version for the fix.


    Made with โค๏ธ and way too much caffeine

    Author: Regi E.
    "Making AI-powered color grading accessible to everyone"