GetMeanSpectrum

Declaration: GetMeanSpectrum(llx, lly, urx, ury, TimeStart, TimeEnd, Group: integer; var Spect: TDoubleArray): integer;
Calculates the mean spectrum of a rectangular range of pixels. The parameters llx and lly denote the lower left corner of the range, the parameters urx and ury specify the upper right corner. The parameters TimeStart and TimeEnd specify the time range. The Group parameter determines the spectral group to be processed (valid range 1..4). The calculated mean spectrum is returned in the Spect array which is automatically resized to take up the entire spectrum.

The function returns the following error codes:

 0 ... everything is OK
-1 ... the specified spectral group does not exist
-2 ... one or more of the parameters llx, lly, urx, or ury are out of range
-3 ... the parameters TimeStart and/or TimeEnd are out of range

Sample Program: The following short example shows how to select a spectrum and how to calculate the mean spectrum of the pixels surrounding the selected position:
program MeanSpec;

const
  QUADSIZE = 5;  // size of quadratic region to be averaged
  PAGE = 1;      // chartbook page

var
  PosX, PosY     : integer;
  Layer          : integer;
  i              : integer;

begin
if SelectSpectrum(PosX, PosY, Layer, 'Please select a position') = 0 then
  begin
  GetMeanSpectrum (PosX-QUADSIZE div 2, PosY-QuadSize div 2,
                   PosX-QUADSIZE div 2+QUADSIZE-1, PosY-QuadSize div 2+QUADSIZE-1,
                   1,1,1,spec);
  ChartBook.Reset;
  ChartBook.Configure
     (PAGE,               // page 1
      true, false, false, // only the chart is visible
      250, 250);          // default width & height
  ChartBook.TabCaption[PAGE] := 'Spectrum';
  with ChartBook.Charts[PAGE] do
    begin
    Reset;
    Caption := 'Mean spectrum at position ['+IntToStr(PosX)+','+IntToStr(PosY)+
               ']; averaged area: '+IntToStr(QUADSIZE)+'x'+IntToStr(QUADSIZE)+
               ' pixels';
    GridStyle := gsDotLines;
    GridColor := clSilver;
    ScalePropsY[1].ShortTicks := false;
    MoveTo(1,spec[0]);
    for i:=1 to MData.CubeSize[dimL] do
      DrawTo (i, spec[i-1]);
    AutoRange (1,4);
    Update;
    end;
  end;
end.