Declaration: |
SelectSpectrum(var PosX, PosY, Layer, TimeSlot: integer; Caption: string): integer; |
Opens the spectrum selection dialog which allows you to select a particular pixel (and a layer) of the image cube. You can move both the cursor in the spectrum (which changes the displayed layer) and the position cursor in the image. When changing the position cursor the corresponding spectrum is displayed in the spectral window at the left. Clicking the OK button selects the current spectrum and layer.
When calling the dialog the variable parameters PosX, PosY, Layer and TimeSlot control the initial cursor positions, on return these parameters contain the selected values (pixel coordinates and layer index). If PosX and PosY are both set to zero values when calling the function, the intial position is set to the center of the image. If the Layer parameter is set to zero the spectral cursor is set to the center of the spectrum. The parameter Caption controls the caption of the dialog, you may leave it empty to display the default caption "Please select a spectrum".
The following image shows the spectrum selection dialog:
The function provides the following return codes:
0 ... everything is OK
-1 ... the initial position [PosX,PosY] is invalid
-2 ... the initial layer is invalid
-3 ... the user cancelled the dialog
|
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;
TimeSlot : integer;
i : integer;
begin
if SelectSpectrum(PosX, PosY, Layer, TimeSlot, '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.
|
|