Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure MedianFilter(const Src: TVec; const Dst: TVec; var State: TMedianState); | Filter data with a median filter. |
| 2 | procedure MedianFilter(const Src: TVec; const Dst: TVec; MaskSize: Integer); | Filter data in Src with a median filter and place the result in Dst. |
| └ indexed: procedure MedianFilter(const Src: TVec; const Dst: TVec; MaskSize: Integer; SrcIndex: Integer; DstIndex: Integer; Len: Integer); | ||
| 3 | procedure MedianFilter(Data: TVec; MaskSize: Integer; DataIndex: Integer; Len: Integer); | Filter data in Data with a median filter from DataIndex to DataIndex+Len and place the result back in the Data. |
Overload 1: procedure MedianFilter(const Src: TVec; const Dst: TVec; var State: TMedianState);
Filter data with a median filter.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TVec | |
| 2 | Dst | TVec | |
| 3 | State | TMedianState |
Result: stored in self (calling object)
Filter data in Src with a median filter configured with a call to MedianInit routine and place the result in the Dst. The length of the Dst will be set to match the Length of the Src. This MedianFilter routine can be used to filter streaming data.
Each output sample is the median of the current sample and the MaskSize-1 preceding samples of the stream. The delay line is initialized to zero by SignalUtils.MedianInit and is carried across consecutive calls, so filtering a signal in chunks of any size gives the same result as filtering it in one call.
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit,OptimalFir;
procedure TForm1.Button1Click(Sender: TObject);
var b,c: Vector;
begin
b.Size(300);
b.SetSubRange(0,150);
b.Ramp(0,1);
b.SetSubRange(150,150);
b.Ramp(150,-1); //creates a triangle
b.SetFullRange;
MedianFilter(b,c,9);
MedianFilter(b,9); //Alternative (in-place)
if not b.Equal(c) then ERaise('Not equal');
end;
Overload 2: procedure MedianFilter(const Src: TVec; const Dst: TVec; MaskSize: Integer);
Filter data in Src with a median filter and place the result in Dst.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TVec | |
| 2 | Dst | TVec | |
| 3 | MaskSize | Integer |
Result: stored in self (calling object)
MaskSize defines the size of the mask for the filter. This MedianFilter routine can be used to filter a block of data. The size of Dst is automatically adjusted.
Each output sample is the median of the current sample and the MaskSize-1 preceding samples; samples preceding the block are taken equal to its first sample. An even MaskSize is reduced to the next lower odd value.
Indexed: procedure MedianFilter(const Src: TVec; const Dst: TVec; MaskSize: Integer; SrcIndex: Integer; DstIndex: Integer; Len: Integer);
Filter data in Src from SrcIndex to SrcIndex+Len with a median filter and place the result in Dst from DstIndex position on.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TVec | |
| 2 | Dst | TVec | |
| 3 | MaskSize | Integer | |
| 4 | SrcIndex | Integer | source start index |
| 5 | DstIndex | Integer | destination start index |
| 6 | Len | Integer | element count |
Result: stored in self (calling object)
MaskSize defines the size of the mask for the filter. This MedianFilter routine can be used to filter a block of data. The size of Dst is not adjusted.
Each output sample is the median of the current sample and the MaskSize-1 preceding samples; samples preceding the block are taken equal to its first sample. An even MaskSize is reduced to the next lower odd value. If MaskSize exceeds the length of Dst, it is reduced to Len.
Overload 3: procedure MedianFilter(Data: TVec; MaskSize: Integer; DataIndex: Integer; Len: Integer);
Filter data in Data with a median filter from DataIndex to DataIndex+Len and place the result back in the Data.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Data | TVec | source TVec |
| 2 | MaskSize | Integer | |
| 3 | DataIndex | Integer | |
| 4 | Len | Integer | element count |
Result: stored in self (calling object)
Set the mask size of the median filter to MaskSize. If Len is MtxVecEOA, the maximum length of the Data vector will be used.
Each output sample is the median of the current sample and the MaskSize-1 preceding samples; samples preceding the block are taken equal to its first sample. An even MaskSize is reduced to the next lower odd value.