Code Monkey home page Code Monkey logo

moving-median-filter's Introduction

Moving-median-filter

Moving median filter based on FIFO buffer.

Library files

Concept Block

                           input
                             +
                             |
                          +--+--+
                          | S/H | <-----------------+ sampling time
                          +--+--+
                             |
                             v
          +------------------+--------------------+
index +-->+                 DEMUX                 |
          +----+------+------+----------------+---+
               |      |      |                |
            +--+-+ +--+-+ +--+-+           +--+-+
            | B0 | | B1 | | B3 | . . . . . | Bn |   <+ buffer
            +-+--+ +-+--+ +-+--+           +-+--+      n is size+1
              |      |      |                |
          +---+------+------+----------------+----+
          |                 SORT                  |
          +----+------+------+----------------+---+
               |      |      |                |
            +--+-+ +--+-+ +--+-+           +--+-+
            | S0 | | S1 | | S2 | . . . . . | Sn |    <+ sorted list
            +-+--+ +-+--+ +-+--+           +-+--+
              |      |      |                |
              +------+------++---------------+
                             |
                    +--------+--------+
                    |  Fill index / 2 |               <+ list
                    +--------+--------+                  med value
                             |
                             v
                          filtered

Code usage

/* Include library */
#include "moving-median.h"

/* Filter objects */
movingMedian_t med_filter;
movingMedian_t med_filter_2;

void main()
{
   /* Initialization of filters */
   moving_median_create(&med_filter, 11, 100);   /* filter size 11, sample time 100ms */
   moving_median_create(&med_filter_2, 29, 150); /* filter size 29, sample time 150ms */

   /* wait for 1 maximum sample time */
   delay(150);

   while(1)
   {
      signal = signal_source();  /* signal source function may ADC, Capture count, sensor data*/

      /* Filter process
      * 
      * call this function maximum passible short time
      */
      moving_median_filter(&med_filter, signal);
      moving_median_filter(&med_filter_2, signal);

      process_or_print = med_filter.filtered;
      process_or_print = med_filter_2.filtered;
   }
}

Filter images

  • channel 0 - signal + noise (+/- 20)
  • channel 1 - filter size 9, sample time 100ms
  • channel 2 - filter size 29, sample time 100ms
  • channel 3 - filter size 49, sample time 100ms

alt text

alt text

Refer other filters

moving-median-filter's People

Contributors

binarymaker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.