#!/usr/bin/env bash
# LEGAL: COPYRIGHT (C) 2010 JIM E. BROOKS WWW.PALOMINO3D.ORG
# Combine LandSat color-band images into one RGB image.

RED_TIF=$1
GREEN_TIF=$2
BLUE_TIF=$3
CHROMA_TIF=$4

tifftopnm $RED_TIF    > r.pgm
tifftopnm $GREEN_TIF  > g.pgm
tifftopnm $BLUE_TIF   > b.pgm
tifftopnm $CHROMA_TIF > chroma.pgm
rgb3toppm r.pgm g.pgm b.pgm > rgb.ppm
pnmscale 2 rgb.ppm > rgb2.ppm
pnmnorm -bvalue 18 -wvalue 156 > pan.pgm < chroma.pgm
pnmarith -add pan.pgm rgb2.ppm | pnmgamma 0.66 > rgbp.ppm
