More scripts: Raster
Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# regress.sml
# Computes coefficents of miltilinear regression equations on a set of rasters.
clear(); # clear the console
raster Rr, Rg, Rb;
class MATRIX h1;
h1 = CreateMatrix(3,3); # holds the results
# get three input rasters to do multiregression on
GetInputRaster(Rr); # get red input raster
if ( RastType(Rr) <> "8-bit unsigned" ) {
PopupMessage( "Only 8 bit unsigned types are supported." );
CloseRaster(Rr); # close it
}
GetInputRaster(Rg); # get green input raster
if ( RastType(Rg) <> "8-bit unsigned" ) {
PopupMessage( "Only 8 bit unsigned types are supported." );
CloseRaster(Rg); # close it
}
GetInputRaster(Rb); # get blue input raster
if ( RastType(Rb) <> "8-bit unsigned" ) {
PopupMessage( "Only 8 bit unsigned types are supported." );
CloseRaster(Rb); # close it
}
# do the multiregression - result in h1
MultiRegression(h1, Rr, Rg, Rb);
printf( "%s\n", "Multi-Regression Output" );
numeric r, c, a;
for r = 0 to 2 {
for c = 0 to 2 {
a = GetMatrixItem( h1, r, c );
printf( "%8.4f ", a );
}
printf( "\n" );
}
CloseRaster(Rr); # do clean up
CloseRaster(Rg);
CloseRaster(Rb);
DestroyMatrix(h1);