Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of filter by
Revision 1:9ce370b360ba, committed 2015-04-01
- Comitter:
- joe4465
- Date:
- Wed Apr 01 11:18:55 2015 +0000
- Parent:
- 0:46a72e790df8
- Commit message:
- ...
Changed in this revision
| filter.cpp | Show annotated file Show diff for this revision Revisions of this file |
| filter.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/filter.cpp Wed Feb 16 20:05:42 2011 +0000
+++ b/filter.cpp Wed Apr 01 11:18:55 2015 +0000
@@ -1,9 +1,9 @@
#include <float.h>
#include "filter.h"
-medianFilter::medianFilter(int window): N(window) {
+filter::filter(int window): N(window) {
big = new bool[N];
- val = new float[N];
+ val = new double[N];
big = new bool[N];
i = 0;
for (int j = 0; j < N; j++) {
@@ -14,8 +14,8 @@
median=0;
}
-int medianFilter::findmax() {
- float m = -FLT_MAX;
+int filter::findmax() {
+ double m = -FLT_MAX;
int n = -1;
for (int j = 0; j < N; j++) {
if (j == med) continue;
@@ -29,8 +29,8 @@
return n;
}
-int medianFilter::findmin() {
- float m = FLT_MAX;
+int filter::findmin() {
+ double m = FLT_MAX;
int n = -1;
for (int j = 0; j < N; j++) {
if (big[j]) { //find min
@@ -43,7 +43,7 @@
return n;
}
-float medianFilter::process(float in) {
+double filter::process(double in) {
//the value at position 'i' is to be replaced by 'in' and the new median is computed
//var 'median' refers to the old median
// val[j] <= median <= val[k]
@@ -79,3 +79,8 @@
median = val[med];
return median;
}
+
+double filter::getMedian()
+{
+ return median;
+}
--- a/filter.h Wed Feb 16 20:05:42 2011 +0000
+++ b/filter.h Wed Apr 01 11:18:55 2015 +0000
@@ -1,24 +1,21 @@
#ifndef FILTER_H
#define FILTER_H
-class filter {
-public:
- virtual float process(float in) {
- return in;
- }
-};
-
-class medianFilter: public filter {
+class filter
+{
+ private:
int N;
- float *val;
+ double *val;
bool *big;
int med, i;
- float median;
+ double median;
int findmax();
int findmin();
-public:
- medianFilter(int window = 3); //every window >= 1 is allowed but the behaviour for even window sizes is not well defined
- virtual float process(float);
+
+ public:
+ filter(int window = 3); //every window >= 1 is allowed but the behaviour for even window sizes is not well defined
+ double process(double);
+ double getMedian();
};
#endif
\ No newline at end of file
