You are here: Symbol Reference > SignalUtils Namespace > Functions > SignalUtils.MedianFilter Function
DSP Master VCL
ContentsIndex
PreviousUpNext
SignalUtils.MedianFilter Function

Filter data in Data with a median filter from DataIndex to DataIndex+Len and place the result back in the Data.

Pascal
procedure MedianFilter(Data: TVec; MaskSize: integer; DataIndex: integer = 0; Len: integer = -1); overload;

Set the mask size of the median filter to MaskSize. If Len is MtxVecEOA, the maximum length of the Data vector will be used.

Median filter applied to a single block of data. 

 

  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;

 

  #include "MtxExpr.hpp"
  #include "MtxVecEdit.hpp"
  #include "MtxVecTee.hpp"
  #include "SignalUtils.hpp"
  #include "OptimalFir.hpp"
  #include <string.h>

  void __fastcall TForm1::BitBtn1Click(TObject *Sender)
  {
      sVector b,c;

      b.Size(300);
       //creates a triangle:
      b(0,149).Ramp(0,1);
      b(150,299).Ramp(150,-1);
      DrawIt(b);

      MedianFilter(b,c,9);
      MedianFilter(b,9); //Alternative (in-place)
      if (!(b.Equal(c))) throw "Not equal";
  }
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!