| 1 | ;+ PURPOSE:
|
|---|
| 2 | ; This makes a 3-color composite image from a set of fits files.
|
|---|
| 3 | ;
|
|---|
| 4 | ; TWEAKABLE PARAMETERS:
|
|---|
| 5 | ; the variables wr, wg, and wb adjust the color balance. They specify
|
|---|
| 6 | ; the red, green, and blue weights.
|
|---|
| 7 | ; rscale, gscale, and bscale determine how much the arcsinh transform
|
|---|
| 8 | ; compresses the dynamic range. Larger values increase dynamic
|
|---|
| 9 | ; range.
|
|---|
| 10 | ;
|
|---|
| 11 | ; DEPENDENCIES:
|
|---|
| 12 | ; This procedure requires the IDL astronomy user's library,
|
|---|
| 13 | ; and the David Fanning Coyote Library.
|
|---|
| 14 | ;-
|
|---|
| 15 | pro color
|
|---|
| 16 |
|
|---|
| 17 | DOSMALL = 0 ;- use heavily binned images to get a quick preview
|
|---|
| 18 | MAKESMALL = 0 ;- create the heavily binned images used by DOSMALL
|
|---|
| 19 |
|
|---|
| 20 | if DOSMALL then goto, small
|
|---|
| 21 |
|
|---|
| 22 | ;- read in images
|
|---|
| 23 | g = mrdfits('i.merge.smooth.fits.flat',0,h, /silent)
|
|---|
| 24 | r = mrdfits('r.merge.smooth.fits.flat',0,h, /silent)
|
|---|
| 25 | b = mrdfits('g.merge.smooth.fits.flat',0,h,/ silent)
|
|---|
| 26 |
|
|---|
| 27 | ;- crop to central 6K by 6K pixels
|
|---|
| 28 | r = float(r[1500:7499, 1500:7499])
|
|---|
| 29 | g = float(g[1500:7499, 1500:7499])
|
|---|
| 30 | b = float(b[1500:7499, 1500:7499])
|
|---|
| 31 |
|
|---|
| 32 | ;- make binned images, save, exit
|
|---|
| 33 | if MAKESMALL then begin
|
|---|
| 34 | r = rebin(r, 600, 600)
|
|---|
| 35 | g = rebin(g, 600, 600)
|
|---|
| 36 | b = rebin(b, 600, 600)
|
|---|
| 37 | save, g, r, b, file='small.sav'
|
|---|
| 38 | return
|
|---|
| 39 | endif
|
|---|
| 40 |
|
|---|
| 41 | small:
|
|---|
| 42 | if DOSMALL then begin
|
|---|
| 43 | if ~file_test('small.sav') then begin
|
|---|
| 44 | print, 'cannot find small.sav. Run MAKESMALL=1 first.'
|
|---|
| 45 | return
|
|---|
| 46 | endif
|
|---|
| 47 | restore, 'small.sav'
|
|---|
| 48 | endif
|
|---|
| 49 |
|
|---|
| 50 | ;- color balance weights
|
|---|
| 51 | wr = .7
|
|---|
| 52 | wg = .7
|
|---|
| 53 | wb = .9
|
|---|
| 54 |
|
|---|
| 55 | ;- black threshhold
|
|---|
| 56 | roff = -10
|
|---|
| 57 | goff = -10
|
|---|
| 58 | boff = -10
|
|---|
| 59 |
|
|---|
| 60 | ;- dynamic range parameters
|
|---|
| 61 | rscale = 25D
|
|---|
| 62 | gscale = 25D
|
|---|
| 63 | bscale = 25D
|
|---|
| 64 |
|
|---|
| 65 | ;- flag bad pixels
|
|---|
| 66 | rbad = r eq 0
|
|---|
| 67 | gbad = g eq 0
|
|---|
| 68 | bbad = b eq 0
|
|---|
| 69 |
|
|---|
| 70 | ;- fill in missing regions that are present in other filters.
|
|---|
| 71 | lum = (r * (1 - rbad) + g * (1 - gbad) + b * (1 - bbad)) / (((1-rbad) + (1-gbad) + (1-bbad)) > 1)
|
|---|
| 72 | r = r * (1 - rbad) + lum * rbad
|
|---|
| 73 | g = g * (1 - gbad) + lum * gbad
|
|---|
| 74 | b = b * (1 - bbad) + lum * bbad
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | bad = (r eq 0) and (g eq 0) and (b eq 0)
|
|---|
| 78 | bad = where(bad, ct, complement = good)
|
|---|
| 79 | if ct ne 0 then begin
|
|---|
| 80 | r[bad] = min(r[good])
|
|---|
| 81 | g[bad] = min(g[good])
|
|---|
| 82 | b[bad] = min(b[good])
|
|---|
| 83 | endif
|
|---|
| 84 |
|
|---|
| 85 | ;- arcsinh transform
|
|---|
| 86 | r = asinh(((r > roff) - roff) / rscale)
|
|---|
| 87 | g = asinh(((g > goff) - goff) / gscale)
|
|---|
| 88 | b = asinh(((b > boff) - boff) / bscale)
|
|---|
| 89 |
|
|---|
| 90 | color:
|
|---|
| 91 |
|
|---|
| 92 | sz = size(r)
|
|---|
| 93 | sz = long(sz)
|
|---|
| 94 |
|
|---|
| 95 | color = fltarr(3, sz[1], sz[2])
|
|---|
| 96 |
|
|---|
| 97 | ;- make the color composite
|
|---|
| 98 | color[0,*,*] = wr * r
|
|---|
| 99 | color[1,*,*] = wg * g
|
|---|
| 100 | color[2,*,*] = wb * b
|
|---|
| 101 |
|
|---|
| 102 | ;-look at the image. Requires the David Fanning COYOTE library
|
|---|
| 103 | tvimage, bytscl(color), /true, /keep
|
|---|
| 104 |
|
|---|
| 105 | ;- save images
|
|---|
| 106 | file='color'
|
|---|
| 107 | if (DOSMALL) then file+='.small'
|
|---|
| 108 | verbiage, 'file saving', 0, 0
|
|---|
| 109 | write_png, file+'.png', bytscl(color)
|
|---|
| 110 | end
|
|---|