meta data for this page
  •  

ReadImage – Spectral Band Arguments

Hoku deals with three kinds of images: monochrome, color and multispectral. A monochrome image has one spectral band. A color image has three: red, green and blue. A multispectral image has more than one band; it could have tens of bands, or even hundreds.

Reading selected bands of an image

If an image has N spectral bands, they are numbered 0 to N-1. A color image has 3 bands: 0 is red, 1 is green and 2 is blue.

The “bands” argument tells ReadImage which bands to read and include in the image it outputs. You are warned if you ask for a band number that does not exist in the input image.

ReadImage with bands set to 0:2

Writing band numbers

You write Meaning Example
single numbers, separated by spaces or semicolons exactly those bands 2 4 5 8
start:stop bands start to stop, and all the bands in between 0:2 reads bands 0, 1 and 2
start+stop bands start to stop, averaged together into one output band 21+40

You can combine them. On a hyperspectral image, 21:40;55;61:70 reads 31 bands, while 21+40;55;61+70 outputs only 3 bands, two of which are averages. A single range uses either : or +, not both.

The same band syntax works in Crop.