Technique to create an RGB image

This is a quick technique to create an RGB image. There surely better ones out there, but this is an idea way to have a bit of fun.

The script below uses a module written by Min-Su Shin. It is freely distributed. There is a download link on an AstroBetter page, I copied it here:

img_scale.py from author Min-Su Shin

Put the file img_scale.py somewhere in your PYTHONPATH, or in the directory where your three processed images are stored.

Eg. If Ureka is in /Users/klabrie/Ureka: cp img_scale.py /Users/klabrie/Ureka/python/lib/python2.7/site-packages/

If you do not know where Ureka is, type: which pyraf. It will show you a path with "Ureka" in it.


In [ ]:
%matplotlib inline

import os
os.chdir('/data/workspace/DRWorkshopAAO/NGC6872/products')

import pyfits
import numpy as np
import matplotlib.pyplot as plt
import img_scale

g_img = pyfits.getdata('ngc6872_g.fits', extname='sci')
i_img = pyfits.getdata('ngc6872_i.fits', extname='sci')
r_img = pyfits.getdata('ngc6872_r.fits', extname='sci')

# I use a square root scaling, but img_scale has linear, log, asinh
# scaling too.
#
# The numbers I use below give an okay result, but it can be improved.

rgbimage = np.zeros((g_img.shape[0], g_img.shape[1], 3), dtype=float)
rgbimage[:,:,2] = img_scale.sqrt(i_img, scale_min=3500, scale_max=40000) 
rgbimage[:,:,1] = img_scale.sqrt(r_img, scale_min=6000, scale_max=40000) 
rgbimage[:,:,0] = img_scale.sqrt(g_img * 1.65, scale_min=3000, scale_max=40000) 

plt.imshow(rgbimage, aspect='equal')
plt.title("Red = i, Green = r', Blue = g'")

# Uncomment the savefig call when you are happy with the look or
# want to see a bigger image.  This will save the file as a PNG
#plt.savefig('ngc6872_rgb.png', dpi=1000)

Or try Gimp

In Gimp, use File -> Open as layer and open all three FITS file. Then go to Color -> Component -> Compose to set the channels. You will want to play with the Channel mixer and the Curves, and whatever can bring the details out.

Objective...


In [ ]: