Logo Search packages:      
Sourcecode: pfstools version File versions  Download package

void Histogram::computeFrequency ( const pfs::Array2D image  ) 

Creates histogram. Histogram will have 'width' bins.

Definition at line 230 of file histogram.cpp.

References pfs::Array2D::getCols(), and pfs::Array2D::getRows().

                                                        {

      const int size = image->getRows()*image->getCols();
      
      frequencyValues = new int[width];
      for( int i = 0; i < width; i++ )
            frequencyValues[i] = 0;                                     
                                                                  
      for( int i = 0; i < size; i++ ) {
      
            float val = (*image)(i);
            if( val <= 0 || val > lumMax) {
                  //fprintf( stderr, "WARNING: pixel luminance out of range (Histogram::computeFrequency())\n");
                  continue;
            }
            
            val = log10(val);

            // Calculate frequency value index in table: <0, with>
            int index = (int)((val - logLumMin) / (logLumMax - logLumMin) * (float)width);
            
            if( index > width || index < 0 ) 
                  continue;
            if( index == width ) 
                  index = width - 1;

            // Increase the counter of this value
            frequencyValues[index] += 1;  
      }
}


Generated by  Doxygen 1.6.0   Back to index