BlueSpray - Help
© SchoonerTurtles, Inc. 2012-2015

Introduction
Contents
Getting Started
Download
Navigating
Tutorials
Scripting
Advanced
About

Class STRaster

Extends STContentBounded

Objects derived from STRaster represent a 2-dimensional raster in memory.
STRaster is the main class for representing raster data in SchoonerTurtle
applications. There are functions below for creating rasters, interogating
their properties, and for converting them to and from traditional and JAI
java objects.

Typically raster transforms will access the data buffers in a raster directly
as this is much faster than using the GetPixel() SetPixel() functions.
IMPORTANT: Call the RasterChanged() function after changing the contents of a
raster so that it's display image will be updated.


Copyright, SchoonerTurtles LLP, 2009
@author Jim Graham
@version A1.0

Enumerated Types

PIXEL_TYPE
    GRAY - Gray
    RGB - RGB
    ARGB - ARGB
    PALETTE - Palette
    N_BAND - N-Band

DATA_TYPE
    UINT8 - Unsigned Byte (8-bit integer)
    UINT16 - Unsigned Short (16-bit integer)
    INT16 - Signed Short (16-bit integer)
    INT32 - Signed Int (32-bit integer)
    FLOAT32 - Float (32-bit floating-point)
    FLOAT64 - Double (64-bit floating-point)

Object Functions

ReturnsFunctionThrows
Copy(STRaster TheInput) Exception
CopyData(STRaster TheInput) Exception
CopyPropertiesButNotData(STRaster TheInput) Exception
DATA_TYPE GetDataType()  
STRaster GetDrawingRaster(boolean StretchFlag,double StretchMin,double StretchMax,
     STColorRamp
TheColorRamp,int Transparency)
Exception
STRaster GetDrawingRasterWithPalette(boolean StretchFlag,double StretchMin,double StretchMax,
     STPalette
NewPalette,int Transparency)
Exception
int GetHeightInPixels()  
STRaster GetMaskAsRaster() Exception
double[][] GetMinMaxes() Exception
int GetNumBands()  
STPalette GetPalette()  
double[] GetPixelByPixelCoordinates(int PixelX,int PixelY) Exception
double[] GetPixelByRef(double RefX,double RefY) Exception
double GetPixelHeightFromRefHeight(double RefHeight)  
double GetPixelWidthFromRefWidth(double RefWidth)  
double GetPixelXFromRefX(double RefX) Exception
double GetPixelYFromRefY(double RefY) Exception
double GetRefHeightFromPixelHeight(double PixelHeight)  
double GetRefWidthFromPixelWidth(double PixelWidth)  
double GetRefXFromPixelX(double PixelX) Exception
double GetRefYFromPixelY(double PixelY) Exception
double GetSample(int PixelX,int PixelY,int Band,double Default) Exception
double GetSampleByRef(double RefX,double RefY,int Band,double Default) Exception
long GetSizeInBytes() Exception
STRaster GetStretchedTo255() Exception
int GetWidthInPixels()  
  STRaster()  
SetDataType(DATA_TYPE NewDataType) Exception
SetHeightInPixels(int NewHeight) Exception
SetNumBands(int New) Exception
SetPalette(STPalette New) Exception // typically used to replace a mask that has been sized
SetPixel(int PixelX,int PixelY,double[] Pixel) Exception
SetPixelByRefCoordinates(double RefX,double RefY,double[] Pixel) Exception
SetSample(int PixelX,int PixelY,int Band,double Value) Exception
SetSampleByRef(double RefX,double RefY,int Band,double Value) Exception
SetWidthInPixels(int NewWidth) Exception

Object Functions


Copy(STRaster TheInput) Exception

Copy the entire contents of one raster into another (both properties and data)

Parameters:
    TheInput
Throws: Exception


CopyData(STRaster TheInput) Exception

Copy the data from another raster. The rasters must match in width, height
data type.

Parameters:
    TheInput - raster to copy information from into this raster


CopyPropertiesButNotData(STRaster TheInput) Exception

Copy the information (settings) from the raster but not the data.

Parameters:
    TheInput - raster to copy information from into this raster


DATA_TYPE GetDataType()  

Returns the data type of the raster in pixels

Returns: Data type of the raster in pixels (DATA_TYPE.UINT8, DATA_TYPE.INT16,DATA_TYPE.UINT16,


STRaster GetDrawingRaster(boolean StretchFlag,double StretchMin,double StretchMax,
     STColorRamp TheColorRamp,int Transparency) Exception

Returns an STRaster for drawing. The raster will always be:
- DataType=UINT8
- PixelType:
- RGB
- RGBA
- GRAY
- PALETTE
- N-BAND: with 2 bands for GRAY with a transparency chennel
The approach is to:
1. Stretch the pixel valuse to go from 0 to 255 between the specified min and max stretch values
2. Set any remaining negative values to 0 and any values > 255 to 255
3. Convert the data to an unsigned 8-bit int (UINT8)
4. If a color ramp is specified, convert the raster to a palette raster with the specified color ramp
6. If the raster is a palette raster and has a mask or is not opaque,
convert the raster to an RGB raster
7.

Parameters:
    StretchFlag - true to stretch image from min to max
    StretchMin - the minimum value in the raster to start the stretch at
    StretchMax - the maximum value for the stretch
    TheColorRamp - An optional color ramp for the output raster
    Transparency - 0 for transparent, 255 for opaque
Returns:
Throws: Exception


STRaster GetDrawingRasterWithPalette(boolean StretchFlag,double StretchMin,double StretchMax,
     STPalette NewPalette,int Transparency) Exception


int GetHeightInPixels()  

Returns the height of the raster in pixels

Returns: Height of the raster in pixels


STRaster GetMaskAsRaster() Exception

Gets the mask that is in this raster.

Returns: null if there is no mask, a new raster otherwise.
Throws: Exception


double[][] GetMinMaxes() Exception

Returns a two-dimesional array with the minimum and maximum values for
each band in the raster. This is separate from the histogram in case all
that is needed is the min/max which is used to stretch an image. If the
histogram is requested, the already computed MinMax array will be passed
to the histogram to save time.

Returns: double[0][0]-Minimum value for band 1


int GetNumBands()  

Gets the number of bands for this raster (e.g. 1 for gray, 3 for RGB)

Returns:


STPalette GetPalette()  

Gets the palette within this raster.

Returns: null if there is no palette, a palette object otherwise.


double[] GetPixelByPixelCoordinates(int PixelX,int PixelY) Exception

Gets the pixel values at a specific location within the raster.

Parameters:
    PixelX - x location of the pixel
    PixelY - y location of the pixel
Returns: an array of doubles with [0] having the value in the first band, [1]


double[] GetPixelByRef(double RefX,double RefY) Exception

Gets the pixel values at a specific reference location within the raster.

Parameters:
    RefX - x location of the pixel
    RefY - y location of the pixel
Returns: an array of doubles with [0] having the value in the first band, [1]


double GetPixelHeightFromRefHeight(double RefHeight)  

Gets the specified reference height (map units) to a height in pixels.

Parameters:
    RefHeight
Returns:


double GetPixelWidthFromRefWidth(double RefWidth)  

Gets the specified reference width (map units) to a width in pixels.

Parameters:
    RefWidth
Returns:


double GetPixelXFromRefX(double RefX) Exception

Returns the horizontal pixel location of a horizontal reference value.

Parameters:
    RefX - the horizontal reference value
Returns: - the horizontal pixel location in the raster


double GetPixelYFromRefY(double RefY) Exception

Returns the vertical pixel location of a vertical reference value.

Parameters:
    RefY - the vertical reference value
Returns: - the vertical pixel location in the raster


double GetRefHeightFromPixelHeight(double PixelHeight)  

Converts a height in pixels to a height in reference units (map units)

Parameters:
    PixelHeight
Returns:


double GetRefWidthFromPixelWidth(double PixelWidth)  

Converts a width in pixels to a a width in reference units (map units)

Parameters:
    PixelWidth -
Returns:


double GetRefXFromPixelX(double PixelX) Exception

Gets a x reference value (map units) from a x pixel locatoin in this raster.

Parameters:
    PixelX
Returns:


double GetRefYFromPixelY(double PixelY) Exception

Gets a y reference value (map units) from a y pixel locatoin in this raster.

Parameters:
    PixelY
Returns:


double GetSample(int PixelX,int PixelY,int Band,double Default) Exception

Gets the value of a sample (single band in a pixel) from a raster.

Parameters:
    PixelX - x location of the desired pixel
    PixelY - y location of the desired pixel
    Band - the desired band (i.e. 0 for the only band in a grayscale image,


double GetSampleByRef(double RefX,double RefY,int Band,double Default) Exception

Gets the value of a sample (single band in a pixel) from a raster.

Parameters:
    RefX - x location of the desired pixel
    RefY - y location of the desired pixel
    Band - the desired band (i.e. 0 for the only band in a grayscale image,


long GetSizeInBytes() Exception

Gets the overall size of the raster in bytes.

Returns:


STRaster GetStretchedTo255() Exception

Returns a copy of the current raster that is stretched from 1 to 255.

Returns:


int GetWidthInPixels()  

Returns the width of the raster in pixels

Returns: Width of the raster in pixels


  STRaster()  



SetDataType(DATA_TYPE NewDataType) Exception

Sets the height of the raster in pixels

Parameters:
    NewDataType Must - be: DATA_TYPE.UINT8, DATA_TYPE.INT16,DATA_TYPE.UINT16,


SetHeightInPixels(int NewHeight) Exception

Sets the height of the raster in pixels

Parameters:
    NewHeight Positive, - integer number of pixels for the height of the image.


SetNumBands(int New) Exception

Sets the number of bands for this raster. This can only be executed
when a raster is not allocated.

Parameters:
    NumBands - The new number of bands (must be 1 to N)


SetPalette(STPalette New) Exception // typically used to replace a mask that has been sized

Sets the palette within this raster.

Parameters:
    ThePalette


SetPixel(int PixelX,int PixelY,double[] Pixel) Exception

Sets a pixel into the raster from a pixel value array. Only works on non-palette
rasters.

Parameters:
    PixelX - x location of the pixel
    PixelY - y location of the pixel
    ThePixel - The array of pixel values for the samples
Throws: Exception


SetPixelByRefCoordinates(double RefX,double RefY,double[] Pixel) Exception

Sets a specific pixel value within a raster based on reference coordinates

Parameters:
    RefX - x location of the pixel
    RefY - y location of the pixel
    ThePixel - The array of pixel values for the samples
Throws: Exception


SetSample(int PixelX,int PixelY,int Band,double Value) Exception

Gets the value of a sample (single band in a pixel) from a raster.

Parameters:
    PixelX - x location of the desired pixel
    PixelY - y location of the desired pixel
    Band - the desired band (i.e. 0 for the only band in a grayscale image,


SetSampleByRef(double RefX,double RefY,int Band,double Value) Exception

Gets the value of a sample (single band in a pixel) from a raster.

Parameters:
    RefX - x location of the desired pixel
    RefY - y location of the desired pixel
    Band - the desired band (i.e. 0 for the only band in a grayscale image,


SetWidthInPixels(int NewWidth) Exception

Sets the width of the raster in pixels

Parameters:
    NewWidth Positive, - integer number of pixels for the width of the image.