Changeset 1373 for trunk/src/MathUtils.cpp
- Timestamp:
- 07/12/07 11:43:56 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MathUtils.cpp
r1325 r1373 32 32 #include <casa/aips.h> 33 33 #include <casa/Arrays/Vector.h> 34 #include <casa/Arrays/Slice.h> 34 35 #include <casa/Arrays/MaskedArray.h> 35 36 #include <casa/Arrays/MaskArrMath.h> 36 37 #include <casa/Arrays/VectorSTLIterator.h> 37 38 #include <casa/BasicSL/String.h> 39 #include <scimath/Mathematics/MedianSlider.h> 38 40 39 41 #include "MathUtils.h" … … 147 149 } 148 150 } 151 152 153 void mathutil::runningMedian(Vector<Float>& out, Vector<Bool>& outflag, 154 const Vector<Float>& in, const Vector<Bool>& flag, 155 float width) 156 { 157 Int hwidth = Int(width+0.5); 158 Int fwidth = hwidth*2+1; 159 out.resize(in.nelements()); 160 outflag.resize(flag.nelements()); 161 MedianSlider ms(hwidth); 162 Slice sl(0, fwidth-1); 163 Float medval = ms.add(const_cast<Vector<Float>& >(in)(sl), 164 const_cast<Vector<Bool>& >(flag)(sl)); 165 uInt n = in.nelements(); 166 for (uInt i=hwidth; i<(n-hwidth); ++i) { 167 // add data value 168 cout << ms.nval() << endl; 169 out[i] = ms.add(in[i], flag[i]); 170 outflag[i] = (ms.nval() == 0); 171 } 172 // replicate edge values from fisrt value with full width of values 173 for (uInt i=0;i<hwidth;++i) { 174 out[i] = out[hwidth]; 175 outflag[i] = outflag[hwidth]; 176 out[n-1-i] = out[n-1-hwidth]; 177 outflag[n-1-i] = outflag[n-1-hwidth]; 178 } 179 }
Note: See TracChangeset
for help on using the changeset viewer.