edit · print · PDF

Please note that all the SIEpedia's articles address specific issues or questions raised by IAC users, so they do not attempt to be rigorous or exhaustive, and may or may not be useful or applicable in different or more general contexts.

How to do an RGB-composite image with pyraf/python

R. Azzollini

#! /usr/bin/env python
'RGB_out', outext='jpg''R':1.,'G':1.,'B''R':0,'G':0,'B':0}):
    # IMPORT STUFF
'mystop module not found. But I can go on...'
    # END IMPORT

    # EXAMPLE OF INPUTS
    # imageR = 'GOODS-Sz_2048zero.fits'
    # imageG = 'GOODS-Sv_2048zero.fits'
    # imageB = 'GOODS-Sb_2048zero.fits'
    # outimage = 'GOODS-Srgb'
    # outext = 'png'

    # doLog = False
    # doBack = True
    # scales = {'R':2.11,'G':0.46,'B':1.}
    # zrange = (0.,0.5)
    # backRGB = {'R':155,'G':62,'B':21}

    # NAME SOME TEMPORAL FILES
'%f''.','_')

    tmpR = 'tmp_Rimg_%s.fits' % ttag
    tmpG = 'tmp_Gimg_%s.fits' % ttag
    tmpB = 'tmp_Bimg_%s.fits'# INNER TASK
# Read-out
# Rescaling
# All values between 0 and 1
# Log scale (optional)
# Background
# Write out
# RE-SCALING OF INPUT IMAGES
'R''R''G''G''B''B'],blank = blank)

    # CALL EXPORT TO DO RGB-COMBINATION (CORE)
'%s,%s,%s'%(tmpR,tmpG,tmpB),outimage,'ppm'"""zscale(b1,0,1),zscale(b2,0,1),zscale(b3,0,1)")

    # FORMAT CONVERSION
'convert %s %s' % (outimage+'.ppm',outimage+'.'+outext))

    # DELETE TEMPORAL FILES
'rm %s %s %s''rm %s' % (outimage+'.ppm',))

###############################################################################################
## to execute the program from the console ####################################################
"__main__"'\nI did not find "mystop" module... hope everything goes fine...'"""\n'combineRGB' is a very simple script devised and shared by        
    Ruyman Azzollini
    (if you have any trouble with the program, contact him at :
ruyman@iac.es, and/or pray for half an hour)\n"
"""-i","--images", dest="images""Input images. EXAMPLE: -i 'R.fits,G.fits,B.fits'.""-o","--outimage",dest="outimage"'RGB_out'"Output image (without extension). Default is 'RGB_out'. EXAMPLE: -o Churri.""-e","--extension",dest="extension"'jpg'"Output image extension. Default is 'jpg'. EXAMPLE: -e png.""-s","--scales",dest="scales"'1,1,1'"Factor by which every image must be multiplied prior to combination, in RGB order. Default is 1 for every band. EXAMPLE: -s '1,1,1'.""-z","--zrange",dest="zrange"'0,1'"Zrange to apply to images prior to combination. Default is (0,1). EXAMPLE: -z '0,1'.""-l","--log",dest="doLog"'False'"Apply logarithmic scaling to images. Default is False. EXAMPLE: -l True.""-b","--background",dest="backRGB"'0,0,0'"'Paint' zones valued as zero in all 3 images in a color given as an RGB 3-value. Default is to leave blank zones in black. EXAMPLE: -b '255,0,0' [Red like Hell]."',',' '),' ''\nNo input images... no output image!\n''\nOutput image will be named "%s" \n''\nOutput image will have "%s" extension\n'',',' '),' ''R':sl[0],'G':sl[1],'B''\nInput images will not be rescaled\n'',',' '),' ''\nZrange will be (0,1)\n''true''\nLinear scaling\n'',',' '),' ''R':bt[0],'G':bt[1],'B''\nBlank zones will appear in Black.\n'

Section: HOWTOs

edit · print · PDF
Page last modified on April 07, 2008, at 11:02 PM