Exemple #1
0
void bob::ip::base::TanTriggs::performContrastEqualization(blitz::Array<double,2>& dst)
{
  const double inv_alpha = 1./m_alpha;
  const double wxh = dst.extent(0)*dst.extent(1);

  // first step: I:=I/mean(abs(I)^a)^(1/a)
  blitz::Range dst_y( dst.lbound(0), dst.ubound(0)),
               dst_x( dst.lbound(1), dst.ubound(1));
  double norm_fact =
    pow( sum( pow( fabs(dst(dst_y,dst_x)), m_alpha)) / wxh, inv_alpha);
  dst(dst_y,dst_x) /= norm_fact;

  // Second step: I:=I/mean(min(threshold,abs(I))^a)^(1/a)
  const double threshold_alpha = pow( m_threshold, m_alpha );
  norm_fact =  pow( sum( min( threshold_alpha,
    pow( fabs(dst(dst_y,dst_x)), m_alpha))) / wxh, inv_alpha);
  dst(dst_y,dst_x) /= norm_fact;

  // Last step: I:= threshold * tanh( I / threshold )
  dst(dst_y,dst_x) = m_threshold * tanh( dst(dst_y,dst_x) / m_threshold );
}
Exemple #2
0
std::string pretty_print(const blitz::Array<T,2> & A)
{ std::stringstream fs;
  for(int i=A.lbound(0);i<=A.ubound(0);i++)
    for(int j=A.lbound(1);j<=A.ubound(1);j++)
      fs<< i<< "  "<<j<<"  "<<A(i,j)<<std::endl;
  return(fs.str());}
Exemple #3
0
std::string pretty_print(const blitz::Array<T,1> & A)
{std::stringstream fs; for (int u =A.lbound(blitz::firstDim);u<=A.ubound(blitz::firstDim);u++) fs<<"  "<<A(u)<<"  ";
  return(fs.str());}