From Open Foris Wiki
oft-reclass changes pixel values to alternative values given in a text file
Usage: oft-reclass [OPTIONS] <infile>
-um <maskfile> -oi <output_image> -maxval <maximum pixel value in infile>
The maxval parameter is used to allocate memory for the reclassification table. If it is not given in the command line, it will be asked interactively.
The reclassification text file should consist of records with input value (column 1) and one or more space separated output values. Thus, the structure could be, for example:
1 255 255 255 2 0 0 0 3 125 100 16 4 0 0 112
The program asks, how many output bands the user wants to produce for each input band. With the given example reclassification file, the user could produce a 3 band RGB image from a single band input file.
- Get Example data set
- For this exercise following tools are used: oft-reclass
- For this exercise we use a single band image images/forestc.tif and a segmented image images/segments.tif which you can also create yourself using oft-seg.
- Go to the folder where you downloaded the data
- First you need to create a text file called input_reclass.txt in the folder txt. The file should look like this:
1 255 255 255 2 0 100 0 3 125 100 16 4 0 0 112 5 0 225 0 6 225 0 0 99 200 0 200
- Now we run oft-reclass with Input: images/forestc.tif and reclassification file txt/input_reclass.txt; Output: results/reclassforestc.img:
oft-reclass -oi results/reclassforestc.img txt/input_reclass.txt images/forestc.tif
- Then tool will ask you then for further information:
Input reclass file name?: txt/input_reclass.txt Nbr of out bands per input channel?:3 Col of input value?: 1 Col of output value 1: 2 Col of output value 2: 3 Col of output value 3: 4 NODATA value?: 0
- Open QGIS and load your the original imagery images/forestc.tif (Colour map: Pseudocolour) and the result results/reclassforestc.img. Click with the Identify Features Tool over the the different classes and see how they have changed after the reclassification:
|Original input image forestc.tif.||Reclassified output raster results/reclassforestc.img.|