Program Dark(Input, Output) ; { Reads all specified images, a strip at a time } { Forms a median image } Uses WinAPI, { No - it's not Windows. It's BP7.0 32-bit stuff } X_U, { My routines for 32-bit addressing } FITSX_U, { Random assortment of FITS read/write stuff } SORT_U ; { Quicksort } Const DarkName = 'C:\BP\TASS\CD5\H4RDARK.FTS' ; { Analysis area } Min2 : Integer = 2 ; Max2 : Integer = 2033 ; Min1 : Integer = 6 ; Max1 : Integer = 2037 ; NFil = 3 ; Name : Array[0..NFil-1] of String = ('D:\IDARK15.FTS', 'D:\IDARK16.FTS', 'D:\IDARK17.FTS') ; Var F : Array[0..NFil-1] of FITSInfoT ; { FITS control structures } Drk : FITSInfoT ; FNo : Integer ; { Count files } I1, I2, N1_M, N2_M : Longint ; L : Array[0..NFil-1] of Integer ; Index : Array[0..NFil-1] of Integer ; W : Longint ;{ Width of strip } Begin N2_M := Max2 - Min2 + 1 ; N1_M := Max1 - Min1 + 1 ; SetHead(Drk, N1_M, N2_M) ; W := 700 ; { Strip width } Repeat If (F[1].Off2 + W > Max2) Then W := Max2 - F[1].Off2 + 1 ; For FNo := 0 to NFil-1 Do Begin Writeln(FNo, ' ', F[NFil-1].Off2, ' ', W) ; { This is a bit Byzantine: ReadStrip and WriteStrip somehow know } { when they are being called for the first time on a particular } { file and act accordingly. I must really get around to fixing } { them so that this is made clear! } ReadStrip(F[FNo], Name[FNo], Min1, N1_M, Min2, W) ; End ; Writeln('Processing') ; For I2 := 0 to W-1 Do For I1 := 0 to N1_M-1 Do Begin For FNo := 0 to NFil-1 Do L[FNo] := IPtr(F[FNo].Image, I2*N1_M+I1)^ ; ISort(L, 0, NFil-1, Index) ; IPtr(Drk.Image, I2*N1_M+I1)^ := L[Index[(NFil-2) Div 2]] ; ; End ; Writeln('Writing from ', Drk.Off2, ' ', W) ; WriteStrip(Drk, DarkName, 99, N1_M, 0, W) ; Writeln('Written to ', Drk.Off2) ; Until (Drk.Off2 >= Drk.NAxis2) ; End. { Dark }