Monday, December 15, 2014

Create a Colored Infra Red (CIR) image from a multi-channel RGBI TIFF file using ImageMagick

Some remote sensing imagery TIFF files contain multiple bands of data such as red, green, blue, and infra-red data. In order to visualize these bands, it is necessary to combine them into an RGB format such as what is called a Colored Infra Red (CIR) display. The open source software ImageMagick can be used to generate the CIR display from the multi-channel TIFF files.

This post illustrates how to create a CIR image from an input RGBI TIFF file. In order to generate a CIR image, the input channels - RGBI has to be reordered to IRG i.e.

  • the file's output red channel is replaced with the input Infra red channel, 
  • the output green channel is replaced with the input red channel, 
  • the output's green channel is replaced with the input green channel, 
  • and the input blue channel is essentially thrown away. 


The ImageMagick command to do this is quite simple, as shown below.

$ convert input_rgbi.tif -channel rgba -separate -swap 1,2 -swap 0,1 -swap 0,3 -channel rgb -combine output_cir.tif

Note: the sequence of options is important.

  • The option -channel rgba instructs the command to read in 4 channels.
  • The option -separate splits the input channels
  • The option -swap 1,2 swaps the 2nd and 3rd channels from RGBI to RBGI
  • The option -swap 0,1 swaps the 1st and 2nd channels from RBGI to BRGI
  • The option -swap 0,3 swaps the 1st and 4th channels from BRGI to IRGB
  • The option -rgb removes the 4th channel to become IRG
  • The option -combine merges all the 3 channels back
The input RGBI file (only the RGB channels are displayed)
The CIR image generated from ImageMagick

No comments:

Related Posts with Thumbnails