warnings
This commit is contained in:
parent
fbe2e6fb01
commit
415978b1c9
@ -199,15 +199,15 @@ void CvHybridTracker::updateTrackerWithEM(Mat image) {
|
|||||||
for (int i = 0; i < proj.rows; i++)
|
for (int i = 0; i < proj.rows; i++)
|
||||||
for (int j = 0; j < proj.cols; j++)
|
for (int j = 0; j < proj.cols; j++)
|
||||||
if (proj.at<double> (i, j) > 0) {
|
if (proj.at<double> (i, j) > 0) {
|
||||||
samples->data.fl[count * 2] = i;
|
samples->data.fl[count * 2] = (float)i;
|
||||||
samples->data.fl[count * 2 + 1] = j;
|
samples->data.fl[count * 2 + 1] = (float)j;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
em_model.train(samples, 0, params.em_params, labels);
|
em_model.train(samples, 0, params.em_params, labels);
|
||||||
|
|
||||||
curr_center.x = em_model.getMeans().at<double> (0, 0);
|
curr_center.x = (float)em_model.getMeans().at<double> (0, 0);
|
||||||
curr_center.y = em_model.getMeans().at<double> (0, 1);
|
curr_center.y = (float)em_model.getMeans().at<double> (0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvHybridTracker::updateTrackerWithLowPassFilter(Mat image) {
|
void CvHybridTracker::updateTrackerWithLowPassFilter(Mat image) {
|
||||||
|
@ -73,459 +73,457 @@
|
|||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
// standard constructor without any log sampling of the input frame
|
// standard constructor without any log sampling of the input frame
|
||||||
RetinaFilter::RetinaFilter(const unsigned int sizeRows, const unsigned int sizeColumns, const bool colorMode, const RETINA_COLORSAMPLINGMETHOD samplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
|
RetinaFilter::RetinaFilter(const unsigned int sizeRows, const unsigned int sizeColumns, const bool colorMode, const RETINA_COLORSAMPLINGMETHOD samplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
|
||||||
:
|
:
|
||||||
_retinaParvoMagnoMappedFrame(0),
|
_retinaParvoMagnoMappedFrame(0),
|
||||||
_retinaParvoMagnoMapCoefTable(0),
|
_retinaParvoMagnoMapCoefTable(0),
|
||||||
_photoreceptorsPrefilter((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor), 4),
|
_photoreceptorsPrefilter((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor), 4),
|
||||||
_ParvoRetinaFilter((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor)),
|
_ParvoRetinaFilter((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor)),
|
||||||
_MagnoRetinaFilter((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor)),
|
_MagnoRetinaFilter((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor)),
|
||||||
_colorEngine((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor), samplingMethod),
|
_colorEngine((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor), samplingMethod),
|
||||||
// configure retina photoreceptors log sampling... if necessary
|
// configure retina photoreceptors log sampling... if necessary
|
||||||
_photoreceptorsLogSampling(NULL)
|
_photoreceptorsLogSampling(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef RETINADEBUG
|
#ifdef RETINADEBUG
|
||||||
std::cout<<"RetinaFilter::size( "<<_photoreceptorsPrefilter.getNBrows()<<", "<<_photoreceptorsPrefilter.getNBcolumns()<<")"<<" =? "<<_photoreceptorsPrefilter.getNBpixels()<<std::endl;
|
std::cout<<"RetinaFilter::size( "<<_photoreceptorsPrefilter.getNBrows()<<", "<<_photoreceptorsPrefilter.getNBcolumns()<<")"<<" =? "<<_photoreceptorsPrefilter.getNBpixels()<<std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (useRetinaLogSampling)
|
if (useRetinaLogSampling)
|
||||||
{
|
{
|
||||||
_photoreceptorsLogSampling = new ImageLogPolProjection(sizeRows, sizeColumns, ImageLogPolProjection::RETINALOGPROJECTION, true);
|
_photoreceptorsLogSampling = new ImageLogPolProjection(sizeRows, sizeColumns, ImageLogPolProjection::RETINALOGPROJECTION, true);
|
||||||
if (!_photoreceptorsLogSampling->initProjection(reductionFactor, samplingStrenght))
|
if (!_photoreceptorsLogSampling->initProjection(reductionFactor, samplingStrenght))
|
||||||
{
|
{
|
||||||
std::cerr<<"RetinaFilter::Problem initializing photoreceptors log sampling, could not setup retina filter"<<std::endl;
|
std::cerr<<"RetinaFilter::Problem initializing photoreceptors log sampling, could not setup retina filter"<<std::endl;
|
||||||
delete _photoreceptorsLogSampling;
|
delete _photoreceptorsLogSampling;
|
||||||
_photoreceptorsLogSampling=NULL;
|
_photoreceptorsLogSampling=NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef RETINADEBUG
|
#ifdef RETINADEBUG
|
||||||
std::cout<<"_photoreceptorsLogSampling::size( "<<_photoreceptorsLogSampling->getNBrows()<<", "<<_photoreceptorsLogSampling->getNBcolumns()<<")"<<" =? "<<_photoreceptorsLogSampling->getNBpixels()<<std::endl;
|
std::cout<<"_photoreceptorsLogSampling::size( "<<_photoreceptorsLogSampling->getNBrows()<<", "<<_photoreceptorsLogSampling->getNBcolumns()<<")"<<" =? "<<_photoreceptorsLogSampling->getNBpixels()<<std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set default processing activities
|
// set default processing activities
|
||||||
_useParvoOutput=true;
|
_useParvoOutput=true;
|
||||||
_useMagnoOutput=true;
|
_useMagnoOutput=true;
|
||||||
|
|
||||||
_useColorMode=colorMode;
|
_useColorMode=colorMode;
|
||||||
|
|
||||||
// create hybrid output and related coefficient table
|
// create hybrid output and related coefficient table
|
||||||
_createHybridTable();
|
_createHybridTable();
|
||||||
|
|
||||||
// set default parameters
|
// set default parameters
|
||||||
setGlobalParameters();
|
setGlobalParameters();
|
||||||
|
|
||||||
// stability controls values init
|
// stability controls values init
|
||||||
_setInitPeriodCount();
|
_setInitPeriodCount();
|
||||||
_globalTemporalConstant=25;
|
_globalTemporalConstant=25;
|
||||||
|
|
||||||
// reset all buffers
|
// reset all buffers
|
||||||
clearAllBuffers();
|
clearAllBuffers();
|
||||||
|
|
||||||
|
|
||||||
// std::cout<<"RetinaFilter::size( "<<this->getNBrows()<<", "<<this->getNBcolumns()<<")"<<_filterOutput.size()<<" =? "<<_filterOutput.getNBpixels()<<std::endl;
|
// std::cout<<"RetinaFilter::size( "<<this->getNBrows()<<", "<<this->getNBcolumns()<<")"<<_filterOutput.size()<<" =? "<<_filterOutput.getNBpixels()<<std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
// destructor
|
||||||
RetinaFilter::~RetinaFilter()
|
RetinaFilter::~RetinaFilter()
|
||||||
{
|
{
|
||||||
if (_photoreceptorsLogSampling!=NULL)
|
if (_photoreceptorsLogSampling!=NULL)
|
||||||
delete _photoreceptorsLogSampling;
|
delete _photoreceptorsLogSampling;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function that clears all buffers of the object
|
// function that clears all buffers of the object
|
||||||
void RetinaFilter::clearAllBuffers()
|
void RetinaFilter::clearAllBuffers()
|
||||||
{
|
{
|
||||||
_photoreceptorsPrefilter.clearAllBuffers();
|
_photoreceptorsPrefilter.clearAllBuffers();
|
||||||
_ParvoRetinaFilter.clearAllBuffers();
|
_ParvoRetinaFilter.clearAllBuffers();
|
||||||
_MagnoRetinaFilter.clearAllBuffers();
|
_MagnoRetinaFilter.clearAllBuffers();
|
||||||
_colorEngine.clearAllBuffers();
|
_colorEngine.clearAllBuffers();
|
||||||
if (_photoreceptorsLogSampling!=NULL)
|
if (_photoreceptorsLogSampling!=NULL)
|
||||||
_photoreceptorsLogSampling->clearAllBuffers();
|
_photoreceptorsLogSampling->clearAllBuffers();
|
||||||
// stability controls value init
|
// stability controls value init
|
||||||
_setInitPeriodCount();
|
_setInitPeriodCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* resize retina filter object (resize all allocated buffers
|
* resize retina filter object (resize all allocated buffers
|
||||||
* @param NBrows: the new height size
|
* @param NBrows: the new height size
|
||||||
* @param NBcolumns: the new width size
|
* @param NBcolumns: the new width size
|
||||||
*/
|
*/
|
||||||
void RetinaFilter::resize(const unsigned int NBrows, const unsigned int NBcolumns)
|
void RetinaFilter::resize(const unsigned int NBrows, const unsigned int NBcolumns)
|
||||||
{
|
{
|
||||||
unsigned int rows=NBrows, cols=NBcolumns;
|
unsigned int rows=NBrows, cols=NBcolumns;
|
||||||
|
|
||||||
// resize optionnal member and adjust other modules size if required
|
// resize optionnal member and adjust other modules size if required
|
||||||
if (_photoreceptorsLogSampling)
|
if (_photoreceptorsLogSampling)
|
||||||
{
|
{
|
||||||
_photoreceptorsLogSampling->resize(NBrows, NBcolumns);
|
_photoreceptorsLogSampling->resize(NBrows, NBcolumns);
|
||||||
rows=_photoreceptorsLogSampling->getOutputNBrows();
|
rows=_photoreceptorsLogSampling->getOutputNBrows();
|
||||||
cols=_photoreceptorsLogSampling->getOutputNBcolumns();
|
cols=_photoreceptorsLogSampling->getOutputNBcolumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
_photoreceptorsPrefilter.resize(rows, cols);
|
_photoreceptorsPrefilter.resize(rows, cols);
|
||||||
_ParvoRetinaFilter.resize(rows, cols);
|
_ParvoRetinaFilter.resize(rows, cols);
|
||||||
_MagnoRetinaFilter.resize(rows, cols);
|
_MagnoRetinaFilter.resize(rows, cols);
|
||||||
_colorEngine.resize(rows, cols);
|
_colorEngine.resize(rows, cols);
|
||||||
|
|
||||||
// reset parvo magno mapping
|
// reset parvo magno mapping
|
||||||
_createHybridTable();
|
_createHybridTable();
|
||||||
|
|
||||||
// clean buffers
|
// clean buffers
|
||||||
clearAllBuffers();
|
clearAllBuffers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// stability controls value init
|
// stability controls value init
|
||||||
void RetinaFilter::_setInitPeriodCount()
|
void RetinaFilter::_setInitPeriodCount()
|
||||||
{
|
{
|
||||||
|
|
||||||
// find out the maximum temporal constant value and apply a security factor
|
// find out the maximum temporal constant value and apply a security factor
|
||||||
// false value (obviously too long) but appropriate for simple use
|
// false value (obviously too long) but appropriate for simple use
|
||||||
_globalTemporalConstant=(unsigned int)(_ParvoRetinaFilter.getPhotoreceptorsTemporalConstant()+_ParvoRetinaFilter.getHcellsTemporalConstant()+_MagnoRetinaFilter.getTemporalConstant());
|
_globalTemporalConstant=(unsigned int)(_ParvoRetinaFilter.getPhotoreceptorsTemporalConstant()+_ParvoRetinaFilter.getHcellsTemporalConstant()+_MagnoRetinaFilter.getTemporalConstant());
|
||||||
// reset frame counter
|
// reset frame counter
|
||||||
_ellapsedFramesSinceLastReset=0;
|
_ellapsedFramesSinceLastReset=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RetinaFilter::_createHybridTable()
|
void RetinaFilter::_createHybridTable()
|
||||||
{
|
{
|
||||||
// create hybrid output and related coefficient table
|
// create hybrid output and related coefficient table
|
||||||
_retinaParvoMagnoMappedFrame.resize(_photoreceptorsPrefilter.getNBpixels());
|
_retinaParvoMagnoMappedFrame.resize(_photoreceptorsPrefilter.getNBpixels());
|
||||||
|
|
||||||
_retinaParvoMagnoMapCoefTable.resize(_photoreceptorsPrefilter.getNBpixels()*2);
|
_retinaParvoMagnoMapCoefTable.resize(_photoreceptorsPrefilter.getNBpixels()*2);
|
||||||
|
|
||||||
// fill _hybridParvoMagnoCoefTable
|
// fill _hybridParvoMagnoCoefTable
|
||||||
int i, j, halfRows=_photoreceptorsPrefilter.getNBrows()/2, halfColumns=_photoreceptorsPrefilter.getNBcolumns()/2;
|
int i, j, halfRows=_photoreceptorsPrefilter.getNBrows()/2, halfColumns=_photoreceptorsPrefilter.getNBcolumns()/2;
|
||||||
float *hybridParvoMagnoCoefTablePTR= &_retinaParvoMagnoMapCoefTable[0];
|
float *hybridParvoMagnoCoefTablePTR= &_retinaParvoMagnoMapCoefTable[0];
|
||||||
float minDistance=(float)MIN(halfRows, halfColumns)*0.7;
|
float minDistance=(float)MIN(halfRows, halfColumns)*0.7;
|
||||||
for (i=0;i<(int)_photoreceptorsPrefilter.getNBrows();++i)
|
for (i=0;i<(int)_photoreceptorsPrefilter.getNBrows();++i)
|
||||||
{
|
{
|
||||||
for (j=0;j<(int)_photoreceptorsPrefilter.getNBcolumns();++j)
|
for (j=0;j<(int)_photoreceptorsPrefilter.getNBcolumns();++j)
|
||||||
{
|
{
|
||||||
float distanceToCenter=sqrt(((float)(i-halfRows)*(i-halfRows)+(j-halfColumns)*(j-halfColumns)));
|
float distanceToCenter=sqrt(((float)(i-halfRows)*(i-halfRows)+(j-halfColumns)*(j-halfColumns)));
|
||||||
if (distanceToCenter<minDistance)
|
if (distanceToCenter<minDistance)
|
||||||
{
|
{
|
||||||
float a=*(hybridParvoMagnoCoefTablePTR++)=0.5+0.5*cos(CV_PI*distanceToCenter/minDistance);
|
float a=*(hybridParvoMagnoCoefTablePTR++)=0.5+0.5*cos(CV_PI*distanceToCenter/minDistance);
|
||||||
*(hybridParvoMagnoCoefTablePTR++)=1.0-a;
|
*(hybridParvoMagnoCoefTablePTR++)=1.0-a;
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
*(hybridParvoMagnoCoefTablePTR++)=0;
|
*(hybridParvoMagnoCoefTablePTR++)=0;
|
||||||
*(hybridParvoMagnoCoefTablePTR++)=1.0;
|
*(hybridParvoMagnoCoefTablePTR++)=1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup parameters function and global data filling
|
// setup parameters function and global data filling
|
||||||
void RetinaFilter::setGlobalParameters(const float OPLspatialResponse1, const float OPLtemporalresponse1, const float OPLassymetryGain, const float OPLspatialResponse2, const float OPLtemporalresponse2, const float LPfilterSpatialResponse, const float LPfilterGain, const float LPfilterTemporalresponse, const float MovingContoursExtractorCoefficient, const bool normalizeParvoOutput_0_maxOutputValue, const bool normalizeMagnoOutput_0_maxOutputValue, const float maxOutputValue, const float maxInputValue, const float meanValue)
|
void RetinaFilter::setGlobalParameters(const float OPLspatialResponse1, const float OPLtemporalresponse1, const float OPLassymetryGain, const float OPLspatialResponse2, const float OPLtemporalresponse2, const float LPfilterSpatialResponse, const float LPfilterGain, const float LPfilterTemporalresponse, const float MovingContoursExtractorCoefficient, const bool normalizeParvoOutput_0_maxOutputValue, const bool normalizeMagnoOutput_0_maxOutputValue, const float maxOutputValue, const float maxInputValue, const float meanValue)
|
||||||
{
|
{
|
||||||
_normalizeParvoOutput_0_maxOutputValue=normalizeParvoOutput_0_maxOutputValue;
|
_normalizeParvoOutput_0_maxOutputValue=normalizeParvoOutput_0_maxOutputValue;
|
||||||
_normalizeMagnoOutput_0_maxOutputValue=normalizeMagnoOutput_0_maxOutputValue;
|
_normalizeMagnoOutput_0_maxOutputValue=normalizeMagnoOutput_0_maxOutputValue;
|
||||||
_maxOutputValue=maxOutputValue;
|
_maxOutputValue=maxOutputValue;
|
||||||
_photoreceptorsPrefilter.setV0CompressionParameter(0.9, maxInputValue, meanValue);
|
_photoreceptorsPrefilter.setV0CompressionParameter(0.9, maxInputValue, meanValue);
|
||||||
_photoreceptorsPrefilter.setLPfilterParameters(10, 0, 1.5, 1); // keeps low pass filter with high cut frequency in memory (usefull for the tone mapping function)
|
_photoreceptorsPrefilter.setLPfilterParameters(10, 0, 1.5, 1); // keeps low pass filter with high cut frequency in memory (usefull for the tone mapping function)
|
||||||
_photoreceptorsPrefilter.setLPfilterParameters(10, 0, 3.0, 2); // keeps low pass filter with low cut frequency in memory (usefull for the tone mapping function)
|
_photoreceptorsPrefilter.setLPfilterParameters(10, 0, 3.0, 2); // keeps low pass filter with low cut frequency in memory (usefull for the tone mapping function)
|
||||||
_photoreceptorsPrefilter.setLPfilterParameters(0, 0, 10, 3); // keeps low pass filter with low cut frequency in memory (usefull for the tone mapping function)
|
_photoreceptorsPrefilter.setLPfilterParameters(0, 0, 10, 3); // keeps low pass filter with low cut frequency in memory (usefull for the tone mapping function)
|
||||||
//this->setV0CompressionParameter(0.6, maxInputValue, meanValue); // keeps log compression sensitivity parameter (usefull for the tone mapping function)
|
//this->setV0CompressionParameter(0.6, maxInputValue, meanValue); // keeps log compression sensitivity parameter (usefull for the tone mapping function)
|
||||||
_ParvoRetinaFilter.setOPLandParvoFiltersParameters(0,OPLtemporalresponse1, OPLspatialResponse1, OPLassymetryGain, OPLtemporalresponse2, OPLspatialResponse2);
|
_ParvoRetinaFilter.setOPLandParvoFiltersParameters(0,OPLtemporalresponse1, OPLspatialResponse1, OPLassymetryGain, OPLtemporalresponse2, OPLspatialResponse2);
|
||||||
_ParvoRetinaFilter.setV0CompressionParameter(0.9, maxInputValue, meanValue);
|
_ParvoRetinaFilter.setV0CompressionParameter(0.9, maxInputValue, meanValue);
|
||||||
_MagnoRetinaFilter.setCoefficientsTable(LPfilterGain, LPfilterTemporalresponse, LPfilterSpatialResponse, MovingContoursExtractorCoefficient, 0, 2.0*LPfilterSpatialResponse);
|
_MagnoRetinaFilter.setCoefficientsTable(LPfilterGain, LPfilterTemporalresponse, LPfilterSpatialResponse, MovingContoursExtractorCoefficient, 0, 2.0*LPfilterSpatialResponse);
|
||||||
_MagnoRetinaFilter.setV0CompressionParameter(0.7, maxInputValue, meanValue);
|
_MagnoRetinaFilter.setV0CompressionParameter(0.7, maxInputValue, meanValue);
|
||||||
|
|
||||||
// stability controls value init
|
// stability controls value init
|
||||||
_setInitPeriodCount();
|
_setInitPeriodCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool RetinaFilter::checkInput(const std::valarray<float> &input, const bool)
|
const bool RetinaFilter::checkInput(const std::valarray<float> &input, const bool)
|
||||||
{
|
{
|
||||||
|
|
||||||
BasicRetinaFilter *inputTarget=&_photoreceptorsPrefilter;
|
BasicRetinaFilter *inputTarget=&_photoreceptorsPrefilter;
|
||||||
if (_photoreceptorsLogSampling)
|
if (_photoreceptorsLogSampling)
|
||||||
inputTarget=_photoreceptorsLogSampling;
|
inputTarget=_photoreceptorsLogSampling;
|
||||||
|
|
||||||
bool test=input.size()==inputTarget->getNBpixels() || input.size()==(inputTarget->getNBpixels()*3) ;
|
bool test=input.size()==inputTarget->getNBpixels() || input.size()==(inputTarget->getNBpixels()*3) ;
|
||||||
if (!test)
|
if (!test)
|
||||||
{
|
{
|
||||||
std::cerr<<"RetinaFilter::checkInput: input buffer does not match retina buffer size, conversion aborted"<<std::endl;
|
std::cerr<<"RetinaFilter::checkInput: input buffer does not match retina buffer size, conversion aborted"<<std::endl;
|
||||||
std::cout<<"RetinaFilter::checkInput: input size="<<input.size()<<" / "<<"retina size="<<inputTarget->getNBpixels()<<std::endl;
|
std::cout<<"RetinaFilter::checkInput: input size="<<input.size()<<" / "<<"retina size="<<inputTarget->getNBpixels()<<std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// main function that runs the filter for a given input frame
|
// main function that runs the filter for a given input frame
|
||||||
const bool RetinaFilter::runFilter(const std::valarray<float> &imageInput, const bool useAdaptiveFiltering, const bool processRetinaParvoMagnoMapping, const bool useColorMode, const bool inputIsColorMultiplexed)
|
const bool RetinaFilter::runFilter(const std::valarray<float> &imageInput, const bool useAdaptiveFiltering, const bool processRetinaParvoMagnoMapping, const bool useColorMode, const bool inputIsColorMultiplexed)
|
||||||
{
|
{
|
||||||
// preliminary check
|
// preliminary check
|
||||||
bool processSuccess=true;
|
bool processSuccess=true;
|
||||||
if (!checkInput(imageInput, useColorMode))
|
if (!checkInput(imageInput, useColorMode))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// run the color multiplexing if needed and compute each suub filter of the retina:
|
// run the color multiplexing if needed and compute each suub filter of the retina:
|
||||||
// -> local adaptation
|
// -> local adaptation
|
||||||
// -> contours OPL extraction
|
// -> contours OPL extraction
|
||||||
// -> moving contours extraction
|
// -> moving contours extraction
|
||||||
|
|
||||||
// stability controls value update
|
// stability controls value update
|
||||||
++_ellapsedFramesSinceLastReset;
|
++_ellapsedFramesSinceLastReset;
|
||||||
|
|
||||||
_useColorMode=useColorMode;
|
_useColorMode=useColorMode;
|
||||||
|
|
||||||
/* pointer to the appropriate input data after,
|
/* pointer to the appropriate input data after,
|
||||||
* by default, if graylevel mode, the input is processed,
|
* by default, if graylevel mode, the input is processed,
|
||||||
* if color or something else must be considered, specific preprocessing are applied
|
* if color or something else must be considered, specific preprocessing are applied
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const std::valarray<float> *selectedPhotoreceptorsLocalAdaptationInput= &imageInput;
|
const std::valarray<float> *selectedPhotoreceptorsLocalAdaptationInput= &imageInput;
|
||||||
const std::valarray<float> *selectedPhotoreceptorsColorInput=&imageInput;
|
const std::valarray<float> *selectedPhotoreceptorsColorInput=&imageInput;
|
||||||
|
|
||||||
//********** Following is input data specific photoreceptors processing
|
//********** Following is input data specific photoreceptors processing
|
||||||
if (_photoreceptorsLogSampling)
|
if (_photoreceptorsLogSampling)
|
||||||
{
|
{
|
||||||
_photoreceptorsLogSampling->runProjection(imageInput, useColorMode);
|
_photoreceptorsLogSampling->runProjection(imageInput, useColorMode);
|
||||||
selectedPhotoreceptorsColorInput=selectedPhotoreceptorsLocalAdaptationInput=&(_photoreceptorsLogSampling->getSampledFrame());
|
selectedPhotoreceptorsColorInput=selectedPhotoreceptorsLocalAdaptationInput=&(_photoreceptorsLogSampling->getSampledFrame());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useColorMode&& (!inputIsColorMultiplexed)) // not multiplexed color input case
|
if (useColorMode&& (!inputIsColorMultiplexed)) // not multiplexed color input case
|
||||||
{
|
{
|
||||||
_colorEngine.runColorMultiplexing(*selectedPhotoreceptorsColorInput);
|
_colorEngine.runColorMultiplexing(*selectedPhotoreceptorsColorInput);
|
||||||
selectedPhotoreceptorsLocalAdaptationInput=&(_colorEngine.getMultiplexedFrame());
|
selectedPhotoreceptorsLocalAdaptationInput=&(_colorEngine.getMultiplexedFrame());
|
||||||
}
|
}
|
||||||
|
|
||||||
//********** Following is generic Retina processing
|
//********** Following is generic Retina processing
|
||||||
|
|
||||||
// photoreceptors local adaptation
|
// photoreceptors local adaptation
|
||||||
_photoreceptorsPrefilter.runFilter_LocalAdapdation(*selectedPhotoreceptorsLocalAdaptationInput, _ParvoRetinaFilter.getHorizontalCellsOutput());
|
_photoreceptorsPrefilter.runFilter_LocalAdapdation(*selectedPhotoreceptorsLocalAdaptationInput, _ParvoRetinaFilter.getHorizontalCellsOutput());
|
||||||
// safety pixel values checks
|
// safety pixel values checks
|
||||||
//_photoreceptorsPrefilter.normalizeGrayOutput_0_maxOutputValue(_maxOutputValue);
|
//_photoreceptorsPrefilter.normalizeGrayOutput_0_maxOutputValue(_maxOutputValue);
|
||||||
|
|
||||||
// run parvo filter
|
// run parvo filter
|
||||||
_ParvoRetinaFilter.runFilter(_photoreceptorsPrefilter.getOutput(), _useParvoOutput);
|
_ParvoRetinaFilter.runFilter(_photoreceptorsPrefilter.getOutput(), _useParvoOutput);
|
||||||
|
|
||||||
if (_useParvoOutput)
|
if (_useParvoOutput)
|
||||||
{
|
{
|
||||||
_ParvoRetinaFilter.normalizeGrayOutputCentredSigmoide(); // models the saturation of the cells, usefull for visualisation of the ON-OFF Parvo Output, Bipolar cells outputs do not change !!!
|
_ParvoRetinaFilter.normalizeGrayOutputCentredSigmoide(); // models the saturation of the cells, usefull for visualisation of the ON-OFF Parvo Output, Bipolar cells outputs do not change !!!
|
||||||
_ParvoRetinaFilter.centerReductImageLuminance(); // best for further spectrum analysis
|
_ParvoRetinaFilter.centerReductImageLuminance(); // best for further spectrum analysis
|
||||||
|
|
||||||
if (_normalizeParvoOutput_0_maxOutputValue)
|
if (_normalizeParvoOutput_0_maxOutputValue)
|
||||||
_ParvoRetinaFilter.normalizeGrayOutput_0_maxOutputValue(_maxOutputValue);
|
_ParvoRetinaFilter.normalizeGrayOutput_0_maxOutputValue(_maxOutputValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_useParvoOutput&&_useMagnoOutput)
|
if (_useParvoOutput&&_useMagnoOutput)
|
||||||
{
|
{
|
||||||
_MagnoRetinaFilter.runFilter(_ParvoRetinaFilter.getBipolarCellsON(), _ParvoRetinaFilter.getBipolarCellsOFF());
|
_MagnoRetinaFilter.runFilter(_ParvoRetinaFilter.getBipolarCellsON(), _ParvoRetinaFilter.getBipolarCellsOFF());
|
||||||
if (_normalizeMagnoOutput_0_maxOutputValue)
|
if (_normalizeMagnoOutput_0_maxOutputValue)
|
||||||
{
|
{
|
||||||
_MagnoRetinaFilter.normalizeGrayOutput_0_maxOutputValue(_maxOutputValue);
|
_MagnoRetinaFilter.normalizeGrayOutput_0_maxOutputValue(_maxOutputValue);
|
||||||
}
|
}
|
||||||
_MagnoRetinaFilter.normalizeGrayOutputNearZeroCentreredSigmoide();
|
_MagnoRetinaFilter.normalizeGrayOutputNearZeroCentreredSigmoide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_useParvoOutput&&_useMagnoOutput&&processRetinaParvoMagnoMapping)
|
if (_useParvoOutput&&_useMagnoOutput&&processRetinaParvoMagnoMapping)
|
||||||
{
|
{
|
||||||
_processRetinaParvoMagnoMapping();
|
_processRetinaParvoMagnoMapping();
|
||||||
if (_useColorMode)
|
if (_useColorMode)
|
||||||
_colorEngine.runColorDemultiplexing(_retinaParvoMagnoMappedFrame, useAdaptiveFiltering, _maxOutputValue);//_ColorEngine->getMultiplexedFrame());//_ParvoRetinaFilter->getPhotoreceptorsLPfilteringOutput());
|
_colorEngine.runColorDemultiplexing(_retinaParvoMagnoMappedFrame, useAdaptiveFiltering, _maxOutputValue);//_ColorEngine->getMultiplexedFrame());//_ParvoRetinaFilter->getPhotoreceptorsLPfilteringOutput());
|
||||||
|
|
||||||
return processSuccess;
|
return processSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_useParvoOutput&&_useColorMode)
|
if (_useParvoOutput&&_useColorMode)
|
||||||
{
|
{
|
||||||
_colorEngine.runColorDemultiplexing(_ParvoRetinaFilter.getOutput(), useAdaptiveFiltering, _maxOutputValue);//_ColorEngine->getMultiplexedFrame());//_ParvoRetinaFilter->getPhotoreceptorsLPfilteringOutput());
|
_colorEngine.runColorDemultiplexing(_ParvoRetinaFilter.getOutput(), useAdaptiveFiltering, _maxOutputValue);//_ColorEngine->getMultiplexedFrame());//_ParvoRetinaFilter->getPhotoreceptorsLPfilteringOutput());
|
||||||
// compute A Cr1 Cr2 to LMS color space conversion
|
// compute A Cr1 Cr2 to LMS color space conversion
|
||||||
//if (true)
|
//if (true)
|
||||||
// _applyImageColorSpaceConversion(_ColorEngine->getChrominance(), lmsTempBuffer.Buffer(), _LMStoACr1Cr2);
|
// _applyImageColorSpaceConversion(_ColorEngine->getChrominance(), lmsTempBuffer.Buffer(), _LMStoACr1Cr2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return processSuccess;
|
return processSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::valarray<float> &RetinaFilter::getContours()
|
const std::valarray<float> &RetinaFilter::getContours()
|
||||||
{
|
{
|
||||||
if (_useColorMode)
|
if (_useColorMode)
|
||||||
return _colorEngine.getLuminance();
|
return _colorEngine.getLuminance();
|
||||||
else
|
else
|
||||||
return _ParvoRetinaFilter.getOutput();
|
return _ParvoRetinaFilter.getOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the initilized retina filter in order to perform gray image tone mapping, after this call all retina outputs are updated
|
// run the initilized retina filter in order to perform gray image tone mapping, after this call all retina outputs are updated
|
||||||
void RetinaFilter::runGrayToneMapping(const std::valarray<float> &grayImageInput, std::valarray<float> &grayImageOutput, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
|
void RetinaFilter::runGrayToneMapping(const std::valarray<float> &grayImageInput, std::valarray<float> &grayImageOutput, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
|
||||||
{
|
{
|
||||||
// preliminary check
|
// preliminary check
|
||||||
if (!checkInput(grayImageInput, false))
|
if (!checkInput(grayImageInput, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this->_runGrayToneMapping(grayImageInput, grayImageOutput, PhotoreceptorsCompression, ganglionCellsCompression);
|
this->_runGrayToneMapping(grayImageInput, grayImageOutput, PhotoreceptorsCompression, ganglionCellsCompression);
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the initilized retina filter in order to perform gray image tone mapping, after this call all retina outputs are updated
|
// run the initilized retina filter in order to perform gray image tone mapping, after this call all retina outputs are updated
|
||||||
void RetinaFilter::_runGrayToneMapping(const std::valarray<float> &grayImageInput, std::valarray<float> &grayImageOutput, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
|
void RetinaFilter::_runGrayToneMapping(const std::valarray<float> &grayImageInput, std::valarray<float> &grayImageOutput, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
|
||||||
{
|
{
|
||||||
// stability controls value update
|
// stability controls value update
|
||||||
++_ellapsedFramesSinceLastReset;
|
++_ellapsedFramesSinceLastReset;
|
||||||
|
|
||||||
std::valarray<float> temp2(grayImageInput.size());
|
std::valarray<float> temp2(grayImageInput.size());
|
||||||
|
|
||||||
// apply tone mapping on the multiplexed image
|
// apply tone mapping on the multiplexed image
|
||||||
// -> photoreceptors local adaptation (large area adaptation)
|
// -> photoreceptors local adaptation (large area adaptation)
|
||||||
_photoreceptorsPrefilter.runFilter_LPfilter(grayImageInput, grayImageOutput, 2); // compute low pass filtering modeling the horizontal cells filtering to acess local luminance
|
_photoreceptorsPrefilter.runFilter_LPfilter(grayImageInput, grayImageOutput, 2); // compute low pass filtering modeling the horizontal cells filtering to acess local luminance
|
||||||
_photoreceptorsPrefilter.setV0CompressionParameterToneMapping(PhotoreceptorsCompression, grayImageOutput.sum()/(float)_photoreceptorsPrefilter.getNBpixels());
|
_photoreceptorsPrefilter.setV0CompressionParameterToneMapping(PhotoreceptorsCompression, grayImageOutput.sum()/(float)_photoreceptorsPrefilter.getNBpixels());
|
||||||
_photoreceptorsPrefilter.runFilter_LocalAdapdation(grayImageInput, grayImageOutput, temp2); // adapt contrast to local luminance
|
_photoreceptorsPrefilter.runFilter_LocalAdapdation(grayImageInput, grayImageOutput, temp2); // adapt contrast to local luminance
|
||||||
|
|
||||||
// high pass filter
|
// high pass filter
|
||||||
//_spatiotemporalLPfilter(_localBuffer, _filterOutput, 2); // compute low pass filtering (high cut frequency (remove spatio-temporal noise)
|
//_spatiotemporalLPfilter(_localBuffer, _filterOutput, 2); // compute low pass filtering (high cut frequency (remove spatio-temporal noise)
|
||||||
|
|
||||||
//for (unsigned int i=0;i<_NBpixels;++i)
|
//for (unsigned int i=0;i<_NBpixels;++i)
|
||||||
// _localBuffer[i]-= _filterOutput[i]/2.0;
|
// _localBuffer[i]-= _filterOutput[i]/2.0;
|
||||||
|
|
||||||
// -> ganglion cells local adaptation (short area adaptation)
|
// -> ganglion cells local adaptation (short area adaptation)
|
||||||
_photoreceptorsPrefilter.runFilter_LPfilter(temp2, grayImageOutput, 1); // compute low pass filtering (high cut frequency (remove spatio-temporal noise)
|
_photoreceptorsPrefilter.runFilter_LPfilter(temp2, grayImageOutput, 1); // compute low pass filtering (high cut frequency (remove spatio-temporal noise)
|
||||||
_photoreceptorsPrefilter.setV0CompressionParameterToneMapping(ganglionCellsCompression, temp2.max(), temp2.sum()/(float)_photoreceptorsPrefilter.getNBpixels());
|
_photoreceptorsPrefilter.setV0CompressionParameterToneMapping(ganglionCellsCompression, temp2.max(), temp2.sum()/(float)_photoreceptorsPrefilter.getNBpixels());
|
||||||
_photoreceptorsPrefilter.runFilter_LocalAdapdation(temp2, grayImageOutput, grayImageOutput); // adapt contrast to local luminance
|
_photoreceptorsPrefilter.runFilter_LocalAdapdation(temp2, grayImageOutput, grayImageOutput); // adapt contrast to local luminance
|
||||||
|
|
||||||
}
|
}
|
||||||
// run the initilized retina filter in order to perform color tone mapping, after this call all retina outputs are updated
|
// run the initilized retina filter in order to perform color tone mapping, after this call all retina outputs are updated
|
||||||
void RetinaFilter::runRGBToneMapping(const std::valarray<float> &RGBimageInput, std::valarray<float> &RGBimageOutput, const bool useAdaptiveFiltering, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
|
void RetinaFilter::runRGBToneMapping(const std::valarray<float> &RGBimageInput, std::valarray<float> &RGBimageOutput, const bool useAdaptiveFiltering, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
|
||||||
{
|
{
|
||||||
// preliminary check
|
// preliminary check
|
||||||
if (!checkInput(RGBimageInput, true))
|
if (!checkInput(RGBimageInput, true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// multiplex the image with the color sampling method specified in the constructor
|
// multiplex the image with the color sampling method specified in the constructor
|
||||||
_colorEngine.runColorMultiplexing(RGBimageInput);
|
_colorEngine.runColorMultiplexing(RGBimageInput);
|
||||||
|
|
||||||
// apply tone mapping on the multiplexed image
|
// apply tone mapping on the multiplexed image
|
||||||
_runGrayToneMapping(_colorEngine.getMultiplexedFrame(), RGBimageOutput, PhotoreceptorsCompression, ganglionCellsCompression);
|
_runGrayToneMapping(_colorEngine.getMultiplexedFrame(), RGBimageOutput, PhotoreceptorsCompression, ganglionCellsCompression);
|
||||||
|
|
||||||
// demultiplex tone maped image
|
// demultiplex tone maped image
|
||||||
_colorEngine.runColorDemultiplexing(RGBimageOutput, useAdaptiveFiltering, _photoreceptorsPrefilter.getMaxInputValue());//_ColorEngine->getMultiplexedFrame());//_ParvoRetinaFilter->getPhotoreceptorsLPfilteringOutput());
|
_colorEngine.runColorDemultiplexing(RGBimageOutput, useAdaptiveFiltering, _photoreceptorsPrefilter.getMaxInputValue());//_ColorEngine->getMultiplexedFrame());//_ParvoRetinaFilter->getPhotoreceptorsLPfilteringOutput());
|
||||||
|
|
||||||
// rescaling result between 0 and 255
|
// rescaling result between 0 and 255
|
||||||
_colorEngine.normalizeRGBOutput_0_maxOutputValue(255.0);
|
_colorEngine.normalizeRGBOutput_0_maxOutputValue(255.0);
|
||||||
|
|
||||||
// return the result
|
// return the result
|
||||||
RGBimageOutput=_colorEngine.getDemultiplexedColorFrame();
|
RGBimageOutput=_colorEngine.getDemultiplexedColorFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RetinaFilter::runLMSToneMapping(const std::valarray<float> &, std::valarray<float> &, const bool, const float, const float)
|
void RetinaFilter::runLMSToneMapping(const std::valarray<float> &, std::valarray<float> &, const bool, const float, const float)
|
||||||
{
|
{
|
||||||
std::cerr<<"not working, sorry"<<std::endl;
|
std::cerr<<"not working, sorry"<<std::endl;
|
||||||
|
|
||||||
/* // preliminary check
|
/* // preliminary check
|
||||||
const std::valarray<float> &bufferInput=checkInput(LMSimageInput, true);
|
const std::valarray<float> &bufferInput=checkInput(LMSimageInput, true);
|
||||||
if (!bufferInput)
|
if (!bufferInput)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!_useColorMode)
|
if (!_useColorMode)
|
||||||
std::cerr<<"RetinaFilter::Can not call tone mapping oeration if the retina filter was created for gray scale images"<<std::endl;
|
std::cerr<<"RetinaFilter::Can not call tone mapping oeration if the retina filter was created for gray scale images"<<std::endl;
|
||||||
|
|
||||||
// create a temporary buffer of size nrows, Mcolumns, 3 layers
|
// create a temporary buffer of size nrows, Mcolumns, 3 layers
|
||||||
std::valarray<float> lmsTempBuffer(LMSimageInput);
|
std::valarray<float> lmsTempBuffer(LMSimageInput);
|
||||||
std::cout<<"RetinaFilter::--->min LMS value="<<lmsTempBuffer.min()<<std::endl;
|
std::cout<<"RetinaFilter::--->min LMS value="<<lmsTempBuffer.min()<<std::endl;
|
||||||
|
|
||||||
// setup local adaptation parameter at the photoreceptors level
|
// setup local adaptation parameter at the photoreceptors level
|
||||||
setV0CompressionParameter(PhotoreceptorsCompression, _maxInputValue);
|
setV0CompressionParameter(PhotoreceptorsCompression, _maxInputValue);
|
||||||
// get the local energy of each color channel
|
// get the local energy of each color channel
|
||||||
// ->L
|
// ->L
|
||||||
_spatiotemporalLPfilter(LMSimageInput, _filterOutput, 1);
|
_spatiotemporalLPfilter(LMSimageInput, _filterOutput, 1);
|
||||||
setV0CompressionParameterToneMapping(PhotoreceptorsCompression, _maxInputValue, this->sum()/_NBpixels);
|
setV0CompressionParameterToneMapping(PhotoreceptorsCompression, _maxInputValue, this->sum()/_NBpixels);
|
||||||
_localLuminanceAdaptation(LMSimageInput, _filterOutput, lmsTempBuffer.Buffer());
|
_localLuminanceAdaptation(LMSimageInput, _filterOutput, lmsTempBuffer.Buffer());
|
||||||
// ->M
|
// ->M
|
||||||
_spatiotemporalLPfilter(LMSimageInput+_NBpixels, _filterOutput, 1);
|
_spatiotemporalLPfilter(LMSimageInput+_NBpixels, _filterOutput, 1);
|
||||||
setV0CompressionParameterToneMapping(PhotoreceptorsCompression, _maxInputValue, this->sum()/_NBpixels);
|
setV0CompressionParameterToneMapping(PhotoreceptorsCompression, _maxInputValue, this->sum()/_NBpixels);
|
||||||
_localLuminanceAdaptation(LMSimageInput+_NBpixels, _filterOutput, lmsTempBuffer.Buffer()+_NBpixels);
|
_localLuminanceAdaptation(LMSimageInput+_NBpixels, _filterOutput, lmsTempBuffer.Buffer()+_NBpixels);
|
||||||
// ->S
|
// ->S
|
||||||
_spatiotemporalLPfilter(LMSimageInput+_NBpixels*2, _filterOutput, 1);
|
_spatiotemporalLPfilter(LMSimageInput+_NBpixels*2, _filterOutput, 1);
|
||||||
setV0CompressionParameterToneMapping(PhotoreceptorsCompression, _maxInputValue, this->sum()/_NBpixels);
|
setV0CompressionParameterToneMapping(PhotoreceptorsCompression, _maxInputValue, this->sum()/_NBpixels);
|
||||||
_localLuminanceAdaptation(LMSimageInput+_NBpixels*2, _filterOutput, lmsTempBuffer.Buffer()+_NBpixels*2);
|
_localLuminanceAdaptation(LMSimageInput+_NBpixels*2, _filterOutput, lmsTempBuffer.Buffer()+_NBpixels*2);
|
||||||
|
|
||||||
// eliminate negative values
|
// eliminate negative values
|
||||||
for (unsigned int i=0;i<lmsTempBuffer.size();++i)
|
for (unsigned int i=0;i<lmsTempBuffer.size();++i)
|
||||||
if (lmsTempBuffer.Buffer()[i]<0)
|
if (lmsTempBuffer.Buffer()[i]<0)
|
||||||
lmsTempBuffer.Buffer()[i]=0;
|
lmsTempBuffer.Buffer()[i]=0;
|
||||||
std::cout<<"RetinaFilter::->min LMS value="<<lmsTempBuffer.min()<<std::endl;
|
std::cout<<"RetinaFilter::->min LMS value="<<lmsTempBuffer.min()<<std::endl;
|
||||||
|
|
||||||
// compute LMS to A Cr1 Cr2 color space conversion
|
// compute LMS to A Cr1 Cr2 color space conversion
|
||||||
_applyImageColorSpaceConversion(lmsTempBuffer.Buffer(), lmsTempBuffer.Buffer(), _LMStoACr1Cr2);
|
_applyImageColorSpaceConversion(lmsTempBuffer.Buffer(), lmsTempBuffer.Buffer(), _LMStoACr1Cr2);
|
||||||
|
|
||||||
TemplateBuffer <float> acr1cr2TempBuffer(_NBrows, _NBcolumns, 3);
|
TemplateBuffer <float> acr1cr2TempBuffer(_NBrows, _NBcolumns, 3);
|
||||||
memcpy(acr1cr2TempBuffer.Buffer(), lmsTempBuffer.Buffer(), sizeof(float)*_NBpixels*3);
|
memcpy(acr1cr2TempBuffer.Buffer(), lmsTempBuffer.Buffer(), sizeof(float)*_NBpixels*3);
|
||||||
|
|
||||||
// compute A Cr1 Cr2 to LMS color space conversion
|
// compute A Cr1 Cr2 to LMS color space conversion
|
||||||
_applyImageColorSpaceConversion(acr1cr2TempBuffer.Buffer(), lmsTempBuffer.Buffer(), _ACr1Cr2toLMS);
|
_applyImageColorSpaceConversion(acr1cr2TempBuffer.Buffer(), lmsTempBuffer.Buffer(), _ACr1Cr2toLMS);
|
||||||
|
|
||||||
// eliminate negative values
|
// eliminate negative values
|
||||||
for (unsigned int i=0;i<lmsTempBuffer.size();++i)
|
for (unsigned int i=0;i<lmsTempBuffer.size();++i)
|
||||||
if (lmsTempBuffer.Buffer()[i]<0)
|
if (lmsTempBuffer.Buffer()[i]<0)
|
||||||
lmsTempBuffer.Buffer()[i]=0;
|
lmsTempBuffer.Buffer()[i]=0;
|
||||||
|
|
||||||
// rewrite output to the appropriate buffer
|
// rewrite output to the appropriate buffer
|
||||||
_colorEngine->setDemultiplexedColorFrame(lmsTempBuffer.Buffer());
|
_colorEngine->setDemultiplexedColorFrame(lmsTempBuffer.Buffer());
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// return image with center Parvo and peripheral Magno channels
|
// return image with center Parvo and peripheral Magno channels
|
||||||
void RetinaFilter::_processRetinaParvoMagnoMapping()
|
void RetinaFilter::_processRetinaParvoMagnoMapping()
|
||||||
{
|
{
|
||||||
register float *hybridParvoMagnoPTR= &_retinaParvoMagnoMappedFrame[0];
|
register float *hybridParvoMagnoPTR= &_retinaParvoMagnoMappedFrame[0];
|
||||||
register const float *parvoOutputPTR= get_data(_ParvoRetinaFilter.getOutput());
|
register const float *parvoOutputPTR= get_data(_ParvoRetinaFilter.getOutput());
|
||||||
register const float *magnoXOutputPTR= get_data(_MagnoRetinaFilter.getOutput());
|
register const float *magnoXOutputPTR= get_data(_MagnoRetinaFilter.getOutput());
|
||||||
register float *hybridParvoMagnoCoefTablePTR= &_retinaParvoMagnoMapCoefTable[0];
|
register float *hybridParvoMagnoCoefTablePTR= &_retinaParvoMagnoMapCoefTable[0];
|
||||||
|
|
||||||
for (unsigned int i=0 ; i<_photoreceptorsPrefilter.getNBpixels() ; ++i, hybridParvoMagnoCoefTablePTR+=2)
|
for (unsigned int i=0 ; i<_photoreceptorsPrefilter.getNBpixels() ; ++i, hybridParvoMagnoCoefTablePTR+=2)
|
||||||
{
|
{
|
||||||
float hybridValue=*(parvoOutputPTR++)**(hybridParvoMagnoCoefTablePTR)+*(magnoXOutputPTR++)**(hybridParvoMagnoCoefTablePTR+1);
|
float hybridValue=*(parvoOutputPTR++)**(hybridParvoMagnoCoefTablePTR)+*(magnoXOutputPTR++)**(hybridParvoMagnoCoefTablePTR+1);
|
||||||
*(hybridParvoMagnoPTR++)=hybridValue;
|
*(hybridParvoMagnoPTR++)=hybridValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateBuffer<float>::normalizeGrayOutput_0_maxOutputValue(&_retinaParvoMagnoMappedFrame[0], _photoreceptorsPrefilter.getNBpixels());
|
TemplateBuffer<float>::normalizeGrayOutput_0_maxOutputValue(&_retinaParvoMagnoMappedFrame[0], _photoreceptorsPrefilter.getNBpixels());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool RetinaFilter::getParvoFoveaResponse(std::valarray<float> &parvoFovealResponse)
|
const bool RetinaFilter::getParvoFoveaResponse(std::valarray<float> &parvoFovealResponse)
|
||||||
{
|
{
|
||||||
if (!_useParvoOutput)
|
if (!_useParvoOutput)
|
||||||
return false;
|
return false;
|
||||||
if (parvoFovealResponse.size() != _ParvoRetinaFilter.getNBpixels())
|
if (parvoFovealResponse.size() != _ParvoRetinaFilter.getNBpixels())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
register const float *parvoOutputPTR= get_data(_ParvoRetinaFilter.getOutput());
|
register const float *parvoOutputPTR= get_data(_ParvoRetinaFilter.getOutput());
|
||||||
register float *fovealParvoResponsePTR= &parvoFovealResponse[0];
|
register float *fovealParvoResponsePTR= &parvoFovealResponse[0];
|
||||||
register float *hybridParvoMagnoCoefTablePTR= &_retinaParvoMagnoMapCoefTable[0];
|
register float *hybridParvoMagnoCoefTablePTR= &_retinaParvoMagnoMapCoefTable[0];
|
||||||
|
|
||||||
for (unsigned int i=0 ; i<_photoreceptorsPrefilter.getNBpixels() ; ++i, hybridParvoMagnoCoefTablePTR+=2)
|
for (unsigned int i=0 ; i<_photoreceptorsPrefilter.getNBpixels() ; ++i, hybridParvoMagnoCoefTablePTR+=2)
|
||||||
{
|
{
|
||||||
*(fovealParvoResponsePTR++)=*(parvoOutputPTR++)**(hybridParvoMagnoCoefTablePTR);
|
*(fovealParvoResponsePTR++)=*(parvoOutputPTR++)**(hybridParvoMagnoCoefTablePTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// method to retrieve the parafoveal magnocellular pathway response (no energy motion in fovea)
|
// method to retrieve the parafoveal magnocellular pathway response (no energy motion in fovea)
|
||||||
const bool RetinaFilter::getMagnoParaFoveaResponse(std::valarray<float> &magnoParafovealResponse)
|
const bool RetinaFilter::getMagnoParaFoveaResponse(std::valarray<float> &magnoParafovealResponse)
|
||||||
{
|
{
|
||||||
if (!_useMagnoOutput)
|
if (!_useMagnoOutput)
|
||||||
return false;
|
return false;
|
||||||
if (magnoParafovealResponse.size() != _MagnoRetinaFilter.getNBpixels())
|
if (magnoParafovealResponse.size() != _MagnoRetinaFilter.getNBpixels())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
register const float *magnoXOutputPTR= get_data(_MagnoRetinaFilter.getOutput());
|
register const float *magnoXOutputPTR= get_data(_MagnoRetinaFilter.getOutput());
|
||||||
register float *parafovealMagnoResponsePTR=&magnoParafovealResponse[0];
|
register float *parafovealMagnoResponsePTR=&magnoParafovealResponse[0];
|
||||||
register float *hybridParvoMagnoCoefTablePTR=&_retinaParvoMagnoMapCoefTable[0]+1;
|
register float *hybridParvoMagnoCoefTablePTR=&_retinaParvoMagnoMapCoefTable[0]+1;
|
||||||
|
|
||||||
for (unsigned int i=0 ; i<_photoreceptorsPrefilter.getNBpixels() ; ++i, hybridParvoMagnoCoefTablePTR+=2)
|
for (unsigned int i=0 ; i<_photoreceptorsPrefilter.getNBpixels() ; ++i, hybridParvoMagnoCoefTablePTR+=2)
|
||||||
{
|
{
|
||||||
*(parafovealMagnoResponsePTR++)=*(magnoXOutputPTR++)**(hybridParvoMagnoCoefTablePTR);
|
*(parafovealMagnoResponsePTR++)=*(magnoXOutputPTR++)**(hybridParvoMagnoCoefTablePTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -287,25 +287,25 @@ std::string CommandLineParser::analizeValue<std::string>(const std::string& str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
int CommandLineParser::analizeValue<int>(const std::string& str, bool space_delete)
|
int CommandLineParser::analizeValue<int>(const std::string& str, bool /*space_delete*/)
|
||||||
{
|
{
|
||||||
return fromStringNumber<int>(str);
|
return fromStringNumber<int>(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
unsigned int CommandLineParser::analizeValue<unsigned int>(const std::string& str, bool space_delete)
|
unsigned int CommandLineParser::analizeValue<unsigned int>(const std::string& str, bool /*space_delete*/)
|
||||||
{
|
{
|
||||||
return fromStringNumber<unsigned int>(str);
|
return fromStringNumber<unsigned int>(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
float CommandLineParser::analizeValue<float>(const std::string& str, bool space_delete)
|
float CommandLineParser::analizeValue<float>(const std::string& str, bool /*space_delete*/)
|
||||||
{
|
{
|
||||||
return fromStringNumber<float>(str);
|
return fromStringNumber<float>(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
double CommandLineParser::analizeValue<double>(const std::string& str, bool space_delete)
|
double CommandLineParser::analizeValue<double>(const std::string& str, bool /*space_delete*/)
|
||||||
{
|
{
|
||||||
return fromStringNumber<double>(str);
|
return fromStringNumber<double>(str);
|
||||||
}
|
}
|
||||||
|
@ -780,14 +780,14 @@ bool CV_OperationsTest::TestVec()
|
|||||||
|
|
||||||
//these compile
|
//these compile
|
||||||
cv::Vec3b b = a;
|
cv::Vec3b b = a;
|
||||||
hsvImage_f.at<cv::Vec3f>(i,j) = cv::Vec3f(i,0,1);
|
hsvImage_f.at<cv::Vec3f>(i,j) = cv::Vec3f((float)i,0,1);
|
||||||
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3b(cv::Vec3f(i,0,1));
|
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3b(cv::Vec3f((float)i,0,1));
|
||||||
|
|
||||||
//these don't
|
//these don't
|
||||||
b = cv::Vec3f(1,0,0);
|
b = cv::Vec3f(1,0,0);
|
||||||
cv::Vec3b c;
|
cv::Vec3b c;
|
||||||
c = cv::Vec3f(0,0,1);
|
c = cv::Vec3f(0,0,1);
|
||||||
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3f(i,0,1);
|
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3f((float)i,0,1);
|
||||||
hsvImage_b.at<cv::Vec3b>(i,j) = a;
|
hsvImage_b.at<cv::Vec3b>(i,j) = a;
|
||||||
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3f(1,2,3);
|
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3f(1,2,3);
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ void cv::createHanningWindow(OutputArray _dst, cv::Size winSize, int type)
|
|||||||
for(int j = 0; j < cols; j++)
|
for(int j = 0; j < cols; j++)
|
||||||
{
|
{
|
||||||
double wc = 0.5 * (1.0f - cos(2.0f * CV_PI * (double)j / (double)(cols - 1)));
|
double wc = 0.5 * (1.0f - cos(2.0f * CV_PI * (double)j / (double)(cols - 1)));
|
||||||
dstData[i*cols + j] = wr * wc;
|
dstData[i*cols + j] = (float)(wr * wc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user