32 arma::uword k = (window_size - 1) / 2;
34 arma::vec filtered = X;
41 for (arma::uword i = k; i < (X.n_rows - k); ++i){
42 buffer = X.subvec(i-k, i+k);
43 sorted = stable_sort_index(buffer);
44 filtered(i) = buffer(sorted(k));
48 }
catch(std::exception e){
49 std::cout << e.what();
64 filtered.set_size(X.n_rows, X.n_cols);
65 for(arma::uword i = 0; i < X.n_cols; ++i)
VESPUCCI_EXPORT arma::vec MedianFilter(const arma::vec &X, arma::uword window_size)
Vespucci::Math::Smoothing::MedianFilter.
VESPUCCI_EXPORT arma::mat MedianFilterMat(const arma::mat &X, arma::uword window_size)
Vespucci::Math::Smoothing::MedianFilterMat.