September 06, 2021 575 words 2 minutes to read

Easily Normalize RGB with Auto-Linear Fit

Easily Normalize RGB with Auto-Linear Fit

Have you ever opened an image from a recent observation only to find it is washed out and looks purple, pink, red, blue, or green? This is common with my sessions. I used to manually use ChannelExtraction to separate the RGB channels, then LinearFit to normalize the channels, and finally uses LRGBCombination to apply them back to the original image. After doing this about a dozen times, I finally broke down and wrote a script to automate it. I call it Auto-Linear Fit.

I made a short video to explain the script and show it in action.

The breakdown is simple. Here is the main dialog:

Auto-Linear Fit Dialog
Auto-Linear Fit Dialog


The options include:

  • Use minimum channel This picks the lowest intensity channel as the baseline for normalization. Unchecked this to choose the highest intensity channel instead.
  • Create new instance By default, the script will apply changes to the original image to preserve history. Check this to leave the original untouched and generate the result in a new instance.
  • Preserve individual channels The script will close the R, G, and B channels when it finishes unless you check this box.
  • Reject low/high This is passed to the LinearFit function to handle clipping low and high range values.
  • Lightness This will change the overall lightness (luminance channel) of the final image. Values below 0.5 will make it lighter, above 0.5 will make it darker.
  • Saturation Slide below 0.5 to increase the saturation and above 0.5 to reduce it.
  • Chrominance noise reduction The LRGBCombination can process noise and remove colored blotches and pixels that are introduced by the saturation function.

To give you an idea of how the different settings work, here is M17: The Omega Nebula, with a strong blue channel:

Original image
Original image


This is after Auto-Linear Fit with the default settings (use minimum channel):

Default settings
Default settings


This one uses the maximum channel (minimum channel unchecked):

Max channel
Max channel


This adjusts the lightness up (setting 0.2):

Lightness setting
Lightness setting


This adjusts it down (setting 0.8):

Darkness setting
Darkness setting


Here’s the desaturated image (setting 0.8):

Desaturated setting
Desaturated setting


For this one, I set saturation to 0.2:

Saturated setting
Saturated setting


And the same setting with noise reduction checked:

Saturated setting with noise reduction
Saturated setting with noise reduction


Enjoy the script! You can download this along with all of my scripts at:

https://github.com/DeepSkyWorkflows/DeepSkyWorkflowScripts

Regards,

Jeremy

Post categories:

Learning 

Related tags: