How to develop your own raw files, Step 4 - separate RGB channels, and adjust for gamma

How to develop your own raw files, Step 4 - separate RGB channels, and adjust for gamma

This post comes after

Raw files converted to tiff need more processing before they turn into viewable color images. I'm assuming you have the offset and dark frame subtracted off your tiff files before following these steps.

I recommend Photoshop CS2 or newer, that's what I happen to have and it's available for free (see my introductory post). It still works on Windows 10. I also assume your camera sensor uses the Bayer color filter pattern RG/GB, like so: RGRGRG GBGBGB RGRGRG GBGBGB

1 Create three 16-bit RGB files of 2x2 pixels. File > New... > Width, height 2 pixels, color mode RGB, 8 bit. For the first file (a mask for the red channel of the Bayer filter pattern), switch to default colors black & white ( D ), zoom in ( CTRL + ) and paint 4 pixels with the 1-pixel pen ( Shift B ) until the icon looks like a pencil. Switch between black & white by pressing ( X ). Paint the pixels in this pattern:


Next, select everything ( CTRL A ) and go to Edit > Define Pattern, call the pattern R. Now for the other two files, create a pattern


and save it as pattern G, and create a pattern


and save it as pattern B.

2 Create a Gamma 1 color profile. This will help Photoshop to display linear images. Go to Edit > Color Settings > Working Spaces > Custom RGB... >

Name: Gamma 1 Gamma: 1

and OK. Then click on Working Spaces > RGB again, and click Save RGB... then, save the profile as

Gamma 1.icc

Now Gamma 1 is a known color space, and you can select it again for RGB working space. Save your settings with Save... and call it

Work with gamma 1 images (linear).scf

Before you click OK again (to close Color Settings), you can now switch your Color Settings > Settings value back to Monitor Color or whatever you had before.

3 Assign the Gamma 1 profile, separate your RGB channels. Open your prepared tiff file, preferably with its offset removed. If not, there will be an extra adjustment with the levels in a moment. PS CS2 is funny with 16-bit files, so zoom in to 100% to make sure you're seeing what is happening with the file.

You may want to record these steps as a Photoshop Action. Show Actions with ( ALT F9 ), optionally create a new set (with the "folder" button) create a new action, with the "new document" button, and give it a name like Separate Bayer RGB.

Convert the gray-scale file to color: go to Image > Mode > RGB color.

Your image is viewed as if the pixel values were encoded with an sRGB gamma 2.2 curve. Switch your image profile to Gamma 1: click Edit > Assign Profile, click Profile, select Gamma 1. Your image should brighten up a lot - if there's much to see. Click OK.

Separate the red channel: Go to Window > Channels, hit ( CTRL 1 ) to switch to the red channel. Go to Edit > Fill..., set Use to Pattern, select the Custom Pattern you made and saved as pattern R. Set Blending to Multiply and Opacity to 100%. Click OK.

Separate the green channel: hit ( CTRL 2 ) to switch to the green channel. Fill with the custom pattern you created for G, make sure to blend with Multiply, opacity 100%.

Separate the blue channel: hit ( CTRL 3 ), fill with the B pattern.

Hit ( CTRL ~ ) to switch back to all channels. Your color channels are now separated.

4 Correct the image levels. If you subtracted a dark frame, or an offset file, or both, your blacks should have a level of 0. Verify this by using the histogram (Window > Histogram). Highlights however, can have any level above 0. For Canon DSLRs, this may be around 16384 / 65536 * 255 = 64 (as shown by Photoshop - the PS UI doesn't deal with 16-bit values very well and everything works with ranges from 0 - 255). To fix this, hit ( CTRL L ), go to Options, select Enhance Monochromatic contrast, select Clip 0.00 for both black and white, click OK, and click Auto to have Photoshop expand your pixel levels to the full range of 0 - 255 (actually, 0 - 65535 since we're working with a 16-bit image). This should brighten up your image considerably. It will have a green color cast, and when zoomed in, you will see the Bayer filter pattern.

My next post will be about creating two custom filters to have Photoshop demosaic your image.

Please comment, correct, ask questions.

Submitted November 28, 2016 at 08:46PM by TheMerovingian from reddit via /r/astrophotography