Sign In

Correcting False Colors in Images Using Stable Diffusion

6

May 3, 2025

(Updated: 4 months ago)

generation guide
Correcting False Colors in Images Using Stable Diffusion

This method corrects false colors in images of people caused by incorrect light balance or non-linear light sources. It uses Stable Diffusion WebUI and Stable Diffusion XL to match the original image as closely as possible, blending the result with the original image using various layering methods.

Prerequisites

  • The Stable Diffusion network (or LoRA) must recognize the person in the image or reproduce them accurately.

Main Method

  1. Prepare the Image:

    • Go to img2img and create positive and negative prompts describing the image.

    • Load the image in img2img, select resize and fill, set denoising strength to 0.5, and CFG scale to 7.

    • Use a resolution of 1280 x 1280 (SDXL can't go higher) and select DPM++ 3M SDE Exponential as the sampler at 40 steps.

    • Enable ADtailer and set inpaint to 0.45.

    • Enable four ControlNet modules, set each control weight to 0.65, and check 'Pixel Perfect'. The modules are:

      • OpenPose

      • Depth

      • Canny (50 - 200)

      • Normal

  2. Generate and Process Images:

    • Generate 16 - 32 images with random seeds.

    • Delete images with a significant offset from the original image, or use fastdup to measure and delete them.

    • Use ImageMagick to average the images: convert *.png -evaluate-sequence Mean mean.ppm.

  3. Blend Images in GIMP:

    • Load the original image in GIMP.

    • Load the mean image and scale it to the size of the original image, or upscale it with WebUI.

    • Paste the mean image as a layer in the original image.

    • Set the layer to 'Lighten only', create a new layer from the visible, and hide it.

    • Set the previous layer to 'LCh Color', create a new layer from the visible, and move it to the top.

    • Make the 'Lighten only' layer visible and set the 'LCh Color' layer to 50% opacity.

    • Create a new layer from the visible. This is the final result.

Alternative Parameters

  • Denoising Strength: Setting it to 0.65 may match the original image more closely but could reintroduce the original problem.

  • LCh Color Layer Opacity: Increase to 75% if minimal artifacts are introduced.

Optional Steps

  • Go to the original layer, select 'Alpha to Selection', and invert the selection.

  • Select the result layer and cut the artifacts from the layer.

  • Mix (opacity) the result layer at 75%.

  • Create a new layer from the visible.

6