void hdrNormalize( Channel32f *channel ) { // first take histogram to find the minimum and maximum values present float minVal, maxVal; getMinMax( *channel, &minVal, &maxVal ); // if min==max then we should just fill with black if( minVal == maxVal ) { fill<float>( channel, 0 ); return; } float scale = 1.0f / ( maxVal - minVal ); Channel32f::Iter iter = channel->getIter(); while( iter.line() ) { while( iter.pixel() ) { iter.v() = ( iter.v() - minVal ) * scale; } } }
void VisualAgitation::update() { if( mCapture && mCapture.checkNewFrame() ) { Channel32f newChan(mCapture.getSurface() ); Channel32f::Iter iterNew = newChan.getIter(); Channel32f::Iter iterOld = mChannel.getIter(); deltaSum = 0.0f; while( iterNew.line() && iterOld.line() ) { while( iterNew.pixel() && iterOld.pixel() ) { deltaSum += fabsf( iterNew.v() - iterOld.v()); } } mChannel = newChan ; } }