I35 Answer ― Exp Transformation


/* Transform image pixels with an exponential function */
void expTransform( image img, double k )
{
  int r, c, p ;

  for ( r=0; r<img.nrows; r++ )
    for ( c=0; c<img.ncols; c++ )
    {
      p = getPixel( img, r, c ) ;
      p = (int)(255* (exp( k*p/255.0) - 1.0) / (exp(k) - 1.0) );
      setPixel( img, r, c, (unsigned char)p );
    }
}

Comments: