Ejemplo n.º 1
0
void lut_interleaver<real>::inverse(const libbase::matrix<real>& in,
      libbase::matrix<real>& out) const
   {
   const int tau = lut.size();
   const int K = in.size().cols();
   assertalways(in.size().rows() == tau);
   out.init(in.size());
   for (int t = 0; t < tau; t++)
      if (lut(t) == fsm::tail)
         for (int i = 0; i < K; i++)
            out(t, i) = real(1.0 / K);
      else
         for (int i = 0; i < K; i++)
            out(lut(t), i) = in(t, i);
   }
Ejemplo n.º 2
0
void limitfilter<T>::process(libbase::matrix<T>& m) const
   {
   const int M = m.size().rows();
   const int N = m.size().cols();

   for (int i = 0; i < M; i++)
      for (int j = 0; j < N; j++)
         if (m(i, j) < m_lo)
            m(i, j) = m_lo;
         else if (m(i, j) > m_hi)
            m(i, j) = m_hi;
   }
Ejemplo n.º 3
0
void limitfilter<T>::process(const libbase::matrix<T>& in, libbase::matrix<T>& out) const
   {
   const int M = in.size().rows();
   const int N = in.size().cols();

   out.init(M, N);

   for (int i = 0; i < M; i++)
      for (int j = 0; j < N; j++)
         if (in(i, j) < m_lo)
            out(i, j) = m_lo;
         else if (in(i, j) > m_hi)
            out(i, j) = m_hi;
         else
            out(i, j) = in(i, j);
   }
Ejemplo n.º 4
0
void variancefilter<T>::process(const libbase::matrix<T>& in,
      libbase::matrix<T>& out) const
   {
   const int M = in.size().rows();
   const int N = in.size().cols();

   out.init(M, N);

   for (int i = 0; i < M; i++)
      for (int j = 0; j < N; j++)
         {
         // compute the variance of neighbouring pixels
         libbase::rvstatistics r;
         for (int ii = std::max(i - m_d, 0); ii <= std::min(i + m_d, M - 1); ii++)
            for (int jj = std::max(j - m_d, 0); jj <= std::min(j + m_d, N - 1); jj++)
               r.insert(double(in(ii, jj)));
         out(i, j) = T(r.var());
         }
   }