Commit 57159998 authored by Alexandre Benoit's avatar Alexandre Benoit

clarified parameters inputs and outputs at the interface level for better…

clarified parameters inputs and outputs at the interface level for better clarity and ease of use, also corrected a mistake at activateContoursProcessing interface method
parent 3970664e
......@@ -114,24 +114,54 @@ class CV_EXPORTS Retina {
public:
// parameters structure for better clarity
struct RetinaParameters{
struct OPLandIplParvoParameters{ // Outer Plexiform Layer (OPL) and Inner Plexiform Layer Parvocellular (IplParvo) parameters
OPLandIplParvoParameters():colorMode(true),
normaliseOutput(true),
photoreceptorsLocalAdaptationSensitivity(0.7),
photoreceptorsTemporalConstant(0.5),
photoreceptorsSpatialConstant(0.53),
horizontalCellsGain(0),
hcellsTemporalConstant(1),
hcellsSpatialConstant(7),
ganglionCellsSensitivity(0.7){};// default setup
bool colorMode, normaliseOutput;
float photoreceptorsLocalAdaptationSensitivity, photoreceptorsTemporalConstant, photoreceptorsSpatialConstant, horizontalCellsGain, hcellsTemporalConstant, hcellsSpatialConstant, ganglionCellsSensitivity;
};
struct IplMagnoParameters{ // Inner Plexiform Layer Magnocellular channel (IplMagno)
IplMagnoParameters():
normaliseOutput(true),
parasolCells_beta(0),
parasolCells_tau(0),
parasolCells_k(7),
amacrinCellsTemporalCutFrequency(1.2),
V0CompressionParameter(0.95),
localAdaptintegration_tau(0),
localAdaptintegration_k(7){};// default setup
bool normaliseOutput;
float parasolCells_beta, parasolCells_tau, parasolCells_k, amacrinCellsTemporalCutFrequency, V0CompressionParameter, localAdaptintegration_tau, localAdaptintegration_k;
};
struct OPLandIplParvoParameters OPLandIplParvo;
struct IplMagnoParameters IplMagno;
};
/**
* Main constructor with most commun use setup : create an instance of color ready retina model
* @param inputSize : the input frame size
* @param parametersSaveFile : the filename of the xml file that records the default retina parameters setup, if empty, then, no default parameter file will be written
*/
Retina(Size inputSize, const std::string parametersSaveFile="");
Retina(Size inputSize);
/**
* Complete Retina filter constructor which allows all basic structural parameters definition
* @param inputSize : the input frame size
* @param parametersSaveFile : the filename of the xml file that records the default retina parameters setup, if empty, then, no default parameter file will be written
* @param colorMode : the chosen processing mode : with or without color processing
* @param colorSamplingMethod: specifies which kind of color sampling will be used
* @param useRetinaLogSampling: activate retina log sampling, if true, the 2 following parameters can be used
* @param reductionFactor: only usefull if param useRetinaLogSampling=true, specifies the reduction factor of the output frame (as the center (fovea) is high resolution and corners can be underscaled, then a reduction of the output is allowed without precision leak
* @param samplingStrenght: only usefull if param useRetinaLogSampling=true, specifies the strenght of the log scale that is applied
*/
Retina(Size inputSize, const std::string parametersSaveFile, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0);
Retina(Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0);
virtual ~Retina();
......@@ -144,12 +174,39 @@ public:
*/
void setup(std::string retinaParameterFile="", const bool applyDefaultSetupOnFailure=true);
/**
* try to open an XML retina parameters file to adjust current retina instance setup
* => if the xml file does not exist, then default setup is applied
* => warning, Exceptions are thrown if read XML file is not valid
* @param newParameters : a parameters structures updated with the new target configuration
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
*/
void setup(RetinaParameters newParameters);
/**
* @return the current parameters setup
*/
struct Retina::RetinaParameters getParameters();
/**
* parameters setup display method
* @return a string which contains formatted parameters information
*/
const std::string printSetup();
/**
* write xml/yml formated parameters information
* @rparam fs : the filename of the xml file that will be open and writen with formatted parameters information
*/
virtual void write( std::string fs ) const;
/**
* write xml/yml formated parameters information
* @param fs : a cv::Filestorage object ready to be filled
*/
virtual void write( FileStorage& fs ) const;
/**
* setup the OPL and IPL parvo channels (see biologocal model)
* OPL is referred as Outer Plexiform Layer of the retina, it allows the spatio-temporal filtering which withens the spectrum and reduces spatio-temporal noise while attenuating global luminance (low frequency energy)
......@@ -238,8 +295,7 @@ public:
protected:
// Parameteres setup members
FileStorage _parametersSaveFile; //!< parameters file ... saved on instance delete
std::string _parametersSaveFileName; //!< parameters file name
RetinaParameters _retinaParameters; // structure of parameters
// Retina model related modules
std::valarray<float> _inputBuffer; //!< buffer used to convert input cv::Mat to internal retina buffers format (valarrays)
......@@ -266,7 +322,7 @@ protected:
const bool _convertCvMat2ValarrayBuffer(const cv::Mat inputMatToConvert, std::valarray<float> &outputValarrayMatrix);
//! private method called by constructors, gathers their parameters and use them in a unified way
void _init(const std::string parametersSaveFileName, Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0);
void _init(const Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0);
};
......
......@@ -75,18 +75,18 @@
namespace cv
{
Retina::Retina(const cv::Size inputSize, const std::string parametersSaveFile)
Retina::Retina(const cv::Size inputSize)
{
_retinaFilter = 0;
_init(parametersSaveFile, inputSize, true, RETINA_COLOR_BAYER, false);
_init(inputSize, true, RETINA_COLOR_BAYER, false);
}
Retina::Retina(const cv::Size inputSize, const std::string parametersSaveFile, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
Retina::Retina(const cv::Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
{
_retinaFilter = 0;
_init(parametersSaveFile, inputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
_init(inputSize, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
};
Retina::~Retina()
{
if (_retinaFilter)
......@@ -98,20 +98,15 @@ void Retina::setColorSaturation(const bool saturateColors, const float colorSatu
_retinaFilter->setColorSaturation(saturateColors, colorSaturationValue);
}
struct Retina::RetinaParameters Retina::getParameters(){return _retinaParameters;}
void Retina::setup(std::string retinaParameterFile, const bool applyDefaultSetupOnFailure)
{
// open specified parameters file
std::cout<<"Retina::setup: setting up retina from parameter file : "<<retinaParameterFile<<std::endl;
// very UGLY cases processing... to be updated...
try
{
// rewriting a new parameter file...
if (_parametersSaveFile.isOpened())
_parametersSaveFile.release();
_parametersSaveFile.open(_parametersSaveFileName, cv::FileStorage::WRITE);
// opening retinaParameterFile in read mode
cv::FileStorage fs(retinaParameterFile, cv::FileStorage::READ);
// read parameters file if it exists or apply default setup if asked for
......@@ -121,37 +116,31 @@ void Retina::setup(std::string retinaParameterFile, const bool applyDefaultSetup
return;
// implicit else case : retinaParameterFile could be open (it exists at least)
}
// preparing parameter setup
bool colorMode, normaliseOutput;
float photoreceptorsLocalAdaptationSensitivity, photoreceptorsTemporalConstant, photoreceptorsSpatialConstant, horizontalCellsGain, hcellsTemporalConstant, hcellsSpatialConstant, ganglionCellsSensitivity;
// OPL and Parvo init first
// OPL and Parvo init first... update at the same time the parameters structure and the retina core
cv::FileNode rootFn = fs.root(), currFn=rootFn["OPLandIPLparvo"];
currFn["colorMode"]>>colorMode;
currFn["normaliseOutput"]>>normaliseOutput;
currFn["photoreceptorsLocalAdaptationSensitivity"]>>photoreceptorsLocalAdaptationSensitivity;
currFn["photoreceptorsTemporalConstant"]>>photoreceptorsTemporalConstant;
currFn["photoreceptorsSpatialConstant"]>>photoreceptorsSpatialConstant;
currFn["horizontalCellsGain"]>>horizontalCellsGain;
currFn["hcellsTemporalConstant"]>>hcellsTemporalConstant;
currFn["hcellsSpatialConstant"]>>hcellsSpatialConstant;
currFn["ganglionCellsSensitivity"]>>ganglionCellsSensitivity;
setupOPLandIPLParvoChannel(colorMode, normaliseOutput, photoreceptorsLocalAdaptationSensitivity, photoreceptorsTemporalConstant, photoreceptorsSpatialConstant, horizontalCellsGain, hcellsTemporalConstant, hcellsSpatialConstant, ganglionCellsSensitivity);
// init retina IPL magno setup
currFn["colorMode"]>>_retinaParameters.OPLandIplParvo.colorMode;
currFn["normaliseOutput"]>>_retinaParameters.OPLandIplParvo.normaliseOutput;
currFn["photoreceptorsLocalAdaptationSensitivity"]>>_retinaParameters.OPLandIplParvo.photoreceptorsLocalAdaptationSensitivity;
currFn["photoreceptorsTemporalConstant"]>>_retinaParameters.OPLandIplParvo.photoreceptorsTemporalConstant;
currFn["photoreceptorsSpatialConstant"]>>_retinaParameters.OPLandIplParvo.photoreceptorsSpatialConstant;
currFn["horizontalCellsGain"]>>_retinaParameters.OPLandIplParvo.horizontalCellsGain;
currFn["hcellsTemporalConstant"]>>_retinaParameters.OPLandIplParvo.hcellsTemporalConstant;
currFn["hcellsSpatialConstant"]>>_retinaParameters.OPLandIplParvo.hcellsSpatialConstant;
currFn["ganglionCellsSensitivity"]>>_retinaParameters.OPLandIplParvo.ganglionCellsSensitivity;
setupOPLandIPLParvoChannel(_retinaParameters.OPLandIplParvo.colorMode, _retinaParameters.OPLandIplParvo.normaliseOutput, _retinaParameters.OPLandIplParvo.photoreceptorsLocalAdaptationSensitivity, _retinaParameters.OPLandIplParvo.photoreceptorsTemporalConstant, _retinaParameters.OPLandIplParvo.photoreceptorsSpatialConstant, _retinaParameters.OPLandIplParvo.horizontalCellsGain, _retinaParameters.OPLandIplParvo.hcellsTemporalConstant, _retinaParameters.OPLandIplParvo.hcellsSpatialConstant, _retinaParameters.OPLandIplParvo.ganglionCellsSensitivity);
// init retina IPL magno setup... update at the same time the parameters structure and the retina core
currFn=rootFn["IPLmagno"];
currFn["normaliseOutput"]>>normaliseOutput;
float parasolCells_beta, parasolCells_tau, parasolCells_k, amacrinCellsTemporalCutFrequency, V0CompressionParameter, localAdaptintegration_tau, localAdaptintegration_k;
currFn["parasolCells_beta"]>>parasolCells_beta;
currFn["parasolCells_tau"]>>parasolCells_tau;
currFn["parasolCells_k"]>>parasolCells_k;
currFn["amacrinCellsTemporalCutFrequency"]>>amacrinCellsTemporalCutFrequency;
currFn["V0CompressionParameter"]>>V0CompressionParameter;
currFn["localAdaptintegration_tau"]>>localAdaptintegration_tau;
currFn["localAdaptintegration_k"]>>localAdaptintegration_k;
setupIPLMagnoChannel(normaliseOutput, parasolCells_beta, parasolCells_tau, parasolCells_k, amacrinCellsTemporalCutFrequency,
V0CompressionParameter, localAdaptintegration_tau, localAdaptintegration_k);
currFn["normaliseOutput"]>>_retinaParameters.IplMagno.normaliseOutput;
currFn["parasolCells_beta"]>>_retinaParameters.IplMagno.parasolCells_beta;
currFn["parasolCells_tau"]>>_retinaParameters.IplMagno.parasolCells_tau;
currFn["parasolCells_k"]>>_retinaParameters.IplMagno.parasolCells_k;
currFn["amacrinCellsTemporalCutFrequency"]>>_retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency;
currFn["V0CompressionParameter"]>>_retinaParameters.IplMagno.V0CompressionParameter;
currFn["localAdaptintegration_tau"]>>_retinaParameters.IplMagno.localAdaptintegration_tau;
currFn["localAdaptintegration_k"]>>_retinaParameters.IplMagno.localAdaptintegration_k;
setupIPLMagnoChannel(_retinaParameters.IplMagno.normaliseOutput, _retinaParameters.IplMagno.parasolCells_beta, _retinaParameters.IplMagno.parasolCells_tau, _retinaParameters.IplMagno.parasolCells_k, _retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency,_retinaParameters.IplMagno.V0CompressionParameter, _retinaParameters.IplMagno.localAdaptintegration_tau, _retinaParameters.IplMagno.localAdaptintegration_k);
}catch(Exception &e)
{
......@@ -164,87 +153,109 @@ void Retina::setup(std::string retinaParameterFile, const bool applyDefaultSetup
std::cout<<"Retina::setup: wrong/unappropriate xml parameter file : error report :`n=>"<<e.what()<<std::endl;
std::cout<<"=> keeping current parameters"<<std::endl;
}
_parametersSaveFile.release(); // close file after setup
// report current configuration
std::cout<<printSetup()<<std::endl;
}
void Retina::setup(cv::Retina::RetinaParameters newConfiguration)
{
// simply copy structures
memcpy(&_retinaParameters, &newConfiguration, sizeof(cv::Retina::RetinaParameters));
// apply setup
setupOPLandIPLParvoChannel(_retinaParameters.OPLandIplParvo.colorMode, _retinaParameters.OPLandIplParvo.normaliseOutput, _retinaParameters.OPLandIplParvo.photoreceptorsLocalAdaptationSensitivity, _retinaParameters.OPLandIplParvo.photoreceptorsTemporalConstant, _retinaParameters.OPLandIplParvo.photoreceptorsSpatialConstant, _retinaParameters.OPLandIplParvo.horizontalCellsGain, _retinaParameters.OPLandIplParvo.hcellsTemporalConstant, _retinaParameters.OPLandIplParvo.hcellsSpatialConstant, _retinaParameters.OPLandIplParvo.ganglionCellsSensitivity);
setupIPLMagnoChannel(_retinaParameters.IplMagno.normaliseOutput, _retinaParameters.IplMagno.parasolCells_beta, _retinaParameters.IplMagno.parasolCells_tau, _retinaParameters.IplMagno.parasolCells_k, _retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency,_retinaParameters.IplMagno.V0CompressionParameter, _retinaParameters.IplMagno.localAdaptintegration_tau, _retinaParameters.IplMagno.localAdaptintegration_k);
}
const std::string Retina::printSetup()
{
std::stringstream outmessage;
try
{
cv::FileStorage parametersReader(_parametersSaveFileName, cv::FileStorage::READ);
if (!parametersReader.isOpened())
{
outmessage<<"Retina is not already settled up";
}
else
{
// accessing xml parameters nodes
cv::FileNode rootFn = parametersReader.root();
cv::FileNode currFn=rootFn["OPLandIPLparvo"];
// displaying OPL and IPL parvo setup
outmessage<<"Current Retina instance setup :"
<<"\nOPLandIPLparvo"<<"{"
<< "\n==> colorMode : " << currFn["colorMode"].operator int()
<< "\n==> normalizeParvoOutput :" << currFn["normaliseOutput"].operator int()
<< "\n==> photoreceptorsLocalAdaptationSensitivity : " << currFn["photoreceptorsLocalAdaptationSensitivity"].operator float()
<< "\n==> photoreceptorsTemporalConstant : " << currFn["photoreceptorsTemporalConstant"].operator float()
<< "\n==> photoreceptorsSpatialConstant : " << currFn["photoreceptorsSpatialConstant"].operator float()
<< "\n==> horizontalCellsGain : " << currFn["horizontalCellsGain"].operator float()
<< "\n==> hcellsTemporalConstant : " << currFn["hcellsTemporalConstant"].operator float()
<< "\n==> hcellsSpatialConstant : " << currFn["hcellsSpatialConstant"].operator float()
<< "\n==> parvoGanglionCellsSensitivity : " << currFn["ganglionCellsSensitivity"].operator float()
<<"}\n";
// displaying IPL magno setup
currFn=rootFn["IPLmagno"];
outmessage<<"Current Retina instance setup :"
<<"\nIPLmagno"<<"{"
<< "\n==> normaliseOutput : " << currFn["normaliseOutput"].operator int()
<< "\n==> parasolCells_beta : " << currFn["parasolCells_beta"].operator float()
<< "\n==> parasolCells_tau : " << currFn["parasolCells_tau"].operator float()
<< "\n==> parasolCells_k : " << currFn["parasolCells_k"].operator float()
<< "\n==> amacrinCellsTemporalCutFrequency : " << currFn["amacrinCellsTemporalCutFrequency"].operator float()
<< "\n==> V0CompressionParameter : " << currFn["V0CompressionParameter"].operator float()
<< "\n==> localAdaptintegration_tau : " << currFn["localAdaptintegration_tau"].operator float()
<< "\n==> localAdaptintegration_k : " << currFn["localAdaptintegration_k"].operator float()
<<"}";
}
}catch(cv::Exception &e)
{
outmessage<<"Error reading parameters configuration file : "<<e.what()<<std::endl;
}
// displaying OPL and IPL parvo setup
outmessage<<"Current Retina instance setup :"
<<"\nOPLandIPLparvo"<<"{"
<< "\n==> colorMode : " << _retinaParameters.OPLandIplParvo.colorMode
<< "\n==> normalizeParvoOutput :" << _retinaParameters.OPLandIplParvo.normaliseOutput
<< "\n==> photoreceptorsLocalAdaptationSensitivity : " << _retinaParameters.OPLandIplParvo.photoreceptorsLocalAdaptationSensitivity
<< "\n==> photoreceptorsTemporalConstant : " << _retinaParameters.OPLandIplParvo.photoreceptorsTemporalConstant
<< "\n==> photoreceptorsSpatialConstant : " << _retinaParameters.OPLandIplParvo.photoreceptorsSpatialConstant
<< "\n==> horizontalCellsGain : " << _retinaParameters.OPLandIplParvo.horizontalCellsGain
<< "\n==> hcellsTemporalConstant : " << _retinaParameters.OPLandIplParvo.hcellsTemporalConstant
<< "\n==> hcellsSpatialConstant : " << _retinaParameters.OPLandIplParvo.hcellsSpatialConstant
<< "\n==> parvoGanglionCellsSensitivity : " << _retinaParameters.OPLandIplParvo.ganglionCellsSensitivity
<<"}\n";
// displaying IPL magno setup
outmessage<<"Current Retina instance setup :"
<<"\nIPLmagno"<<"{"
<< "\n==> normaliseOutput : " << _retinaParameters.IplMagno.normaliseOutput
<< "\n==> parasolCells_beta : " << _retinaParameters.IplMagno.parasolCells_beta
<< "\n==> parasolCells_tau : " << _retinaParameters.IplMagno.parasolCells_tau
<< "\n==> parasolCells_k : " << _retinaParameters.IplMagno.parasolCells_k
<< "\n==> amacrinCellsTemporalCutFrequency : " << _retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency
<< "\n==> V0CompressionParameter : " << _retinaParameters.IplMagno.V0CompressionParameter
<< "\n==> localAdaptintegration_tau : " << _retinaParameters.IplMagno.localAdaptintegration_tau
<< "\n==> localAdaptintegration_k : " << _retinaParameters.IplMagno.localAdaptintegration_k
<<"}";
return outmessage.str();
}
void Retina::write( std::string fs ) const
{
FileStorage parametersSaveFile(fs, cv::FileStorage::WRITE );
write(parametersSaveFile);
}
void Retina::write( FileStorage& fs ) const
{
if (!fs.isOpened())
return; // basic error case
fs<<"OPLandIPLparvo"<<"{";
fs << "colorMode" << _retinaParameters.OPLandIplParvo.colorMode;
fs << "normaliseOutput" << _retinaParameters.OPLandIplParvo.normaliseOutput;
fs << "photoreceptorsLocalAdaptationSensitivity" << _retinaParameters.OPLandIplParvo.photoreceptorsLocalAdaptationSensitivity;
fs << "photoreceptorsTemporalConstant" << _retinaParameters.OPLandIplParvo.photoreceptorsTemporalConstant;
fs << "photoreceptorsSpatialConstant" << _retinaParameters.OPLandIplParvo.photoreceptorsSpatialConstant;
fs << "horizontalCellsGain" << _retinaParameters.OPLandIplParvo.horizontalCellsGain;
fs << "hcellsTemporalConstant" << _retinaParameters.OPLandIplParvo.hcellsTemporalConstant;
fs << "hcellsSpatialConstant" << _retinaParameters.OPLandIplParvo.hcellsSpatialConstant;
fs << "ganglionCellsSensitivity" << _retinaParameters.OPLandIplParvo.ganglionCellsSensitivity;
fs << "}";
fs<<"IPLmagno"<<"{";
fs << "normaliseOutput" << _retinaParameters.IplMagno.normaliseOutput;
fs << "parasolCells_beta" << _retinaParameters.IplMagno.parasolCells_beta;
fs << "parasolCells_tau" << _retinaParameters.IplMagno.parasolCells_tau;
fs << "parasolCells_k" << _retinaParameters.IplMagno.parasolCells_k;
fs << "amacrinCellsTemporalCutFrequency" << _retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency;
fs << "V0CompressionParameter" << _retinaParameters.IplMagno.V0CompressionParameter;
fs << "localAdaptintegration_tau" << _retinaParameters.IplMagno.localAdaptintegration_tau;
fs << "localAdaptintegration_k" << _retinaParameters.IplMagno.localAdaptintegration_k;
fs<<"}";
}
void Retina::setupOPLandIPLParvoChannel(const bool colorMode, const bool normaliseOutput, const float photoreceptorsLocalAdaptationSensitivity, const float photoreceptorsTemporalConstant, const float photoreceptorsSpatialConstant, const float horizontalCellsGain, const float HcellsTemporalConstant, const float HcellsSpatialConstant, const float ganglionCellsSensitivity)
{
// parameters setup (default setup)
// retina core parameters setup
_retinaFilter->setColorMode(colorMode);
_retinaFilter->setPhotoreceptorsLocalAdaptationSensitivity(photoreceptorsLocalAdaptationSensitivity);
_retinaFilter->setOPLandParvoParameters(0, photoreceptorsTemporalConstant, photoreceptorsSpatialConstant, horizontalCellsGain, HcellsTemporalConstant, HcellsSpatialConstant, ganglionCellsSensitivity);
_retinaFilter->setParvoGanglionCellsLocalAdaptationSensitivity(ganglionCellsSensitivity);
_retinaFilter->activateNormalizeParvoOutput_0_maxOutputValue(normaliseOutput);
// update parameters struture
_retinaParameters.OPLandIplParvo.colorMode = colorMode;
_retinaParameters.OPLandIplParvo.normaliseOutput = normaliseOutput;
_retinaParameters.OPLandIplParvo.photoreceptorsLocalAdaptationSensitivity = photoreceptorsLocalAdaptationSensitivity;
_retinaParameters.OPLandIplParvo.photoreceptorsTemporalConstant = photoreceptorsTemporalConstant;
_retinaParameters.OPLandIplParvo.photoreceptorsSpatialConstant = photoreceptorsSpatialConstant;
_retinaParameters.OPLandIplParvo.horizontalCellsGain = horizontalCellsGain;
_retinaParameters.OPLandIplParvo.hcellsTemporalConstant = HcellsTemporalConstant;
_retinaParameters.OPLandIplParvo.hcellsSpatialConstant = HcellsSpatialConstant;
_retinaParameters.OPLandIplParvo.ganglionCellsSensitivity = ganglionCellsSensitivity;
// save parameters in the xml parameters tree... if parameters file is already open
if (!_parametersSaveFile.isOpened())
return;
_parametersSaveFile<<"OPLandIPLparvo"<<"{";
_parametersSaveFile << "colorMode" << colorMode;
_parametersSaveFile << "normaliseOutput" << normaliseOutput;
_parametersSaveFile << "photoreceptorsLocalAdaptationSensitivity" << photoreceptorsLocalAdaptationSensitivity;
_parametersSaveFile << "photoreceptorsTemporalConstant" << photoreceptorsTemporalConstant;
_parametersSaveFile << "photoreceptorsSpatialConstant" << photoreceptorsSpatialConstant;
_parametersSaveFile << "horizontalCellsGain" << horizontalCellsGain;
_parametersSaveFile << "hcellsTemporalConstant" << HcellsTemporalConstant;
_parametersSaveFile << "hcellsSpatialConstant" << HcellsSpatialConstant;
_parametersSaveFile << "ganglionCellsSensitivity" << ganglionCellsSensitivity;
_parametersSaveFile << "}";
}
void Retina::setupIPLMagnoChannel(const bool normaliseOutput, const float parasolCells_beta, const float parasolCells_tau, const float parasolCells_k, const float amacrinCellsTemporalCutFrequency, const float V0CompressionParameter, const float localAdaptintegration_tau, const float localAdaptintegration_k)
......@@ -253,20 +264,15 @@ void Retina::setupIPLMagnoChannel(const bool normaliseOutput, const float paraso
_retinaFilter->setMagnoCoefficientsTable(parasolCells_beta, parasolCells_tau, parasolCells_k, amacrinCellsTemporalCutFrequency, V0CompressionParameter, localAdaptintegration_tau, localAdaptintegration_k);
_retinaFilter->activateNormalizeMagnoOutput_0_maxOutputValue(normaliseOutput);
// save parameters in the xml parameters tree... if parameters file is already open
if (!_parametersSaveFile.isOpened())
return;
_parametersSaveFile<<"IPLmagno"<<"{";
_parametersSaveFile << "normaliseOutput" << normaliseOutput;
_parametersSaveFile << "parasolCells_beta" << parasolCells_beta;
_parametersSaveFile << "parasolCells_tau" << parasolCells_tau;
_parametersSaveFile << "parasolCells_k" << parasolCells_k;
_parametersSaveFile << "amacrinCellsTemporalCutFrequency" << amacrinCellsTemporalCutFrequency;
_parametersSaveFile << "V0CompressionParameter" << V0CompressionParameter;
_parametersSaveFile << "localAdaptintegration_tau" << localAdaptintegration_tau;
_parametersSaveFile << "localAdaptintegration_k" << localAdaptintegration_k;
_parametersSaveFile<<"}";
// update parameters struture
_retinaParameters.IplMagno.normaliseOutput = normaliseOutput;
_retinaParameters.IplMagno.parasolCells_beta = parasolCells_beta;
_retinaParameters.IplMagno.parasolCells_tau = parasolCells_tau;
_retinaParameters.IplMagno.parasolCells_k = parasolCells_k;
_retinaParameters.IplMagno.amacrinCellsTemporalCutFrequency = amacrinCellsTemporalCutFrequency;
_retinaParameters.IplMagno.V0CompressionParameter = V0CompressionParameter;
_retinaParameters.IplMagno.localAdaptintegration_tau = localAdaptintegration_tau;
_retinaParameters.IplMagno.localAdaptintegration_k = localAdaptintegration_k;
}
void Retina::run(const cv::Mat &inputMatToConvert)
......@@ -303,10 +309,8 @@ void Retina::getMagno(std::valarray<float> &){_retinaFilter->getMovingContours()
void Retina::getParvo(std::valarray<float> &){_retinaFilter->getContours();}
// private method called by constructirs
void Retina::_init(const std::string parametersSaveFileName, const cv::Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
void Retina::_init(const cv::Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
{
_parametersSaveFileName = parametersSaveFileName;
// basic error check
if (inputSize.height*inputSize.width <= 0)
throw cv::Exception(-1, "Bad retina size setup : size height and with must be superior to zero", "Retina::setup", "Retina.h", 0);
......@@ -321,23 +325,8 @@ void Retina::_init(const std::string parametersSaveFileName, const cv::Size inpu
_retinaFilter = new RetinaFilter(inputSize.height, inputSize.width, colorMode, colorSamplingMethod, useRetinaLogSampling, reductionFactor, samplingStrenght);
// prepare the default parameter XML file with default setup
if (_parametersSaveFileName.size()>0)
{
_parametersSaveFile.open(parametersSaveFileName, cv::FileStorage::WRITE );
_parametersSaveFile<<"InputSize"<<"{";
_parametersSaveFile<<"height"<<inputSize.height;
_parametersSaveFile<<"width"<<inputSize.width;
_parametersSaveFile<<"}";
setup(_retinaParameters);
// clear all retina buffers
// apply default setup
setupOPLandIPLParvoChannel();
setupIPLMagnoChannel();
// write current parameters to params file
_parametersSaveFile.release();
}
// init retina
_retinaFilter->clearAllBuffers();
......@@ -433,7 +422,7 @@ void Retina::clearBuffers() {_retinaFilter->clearAllBuffers();}
void Retina::activateMovingContoursProcessing(const bool activate){_retinaFilter->activateMovingContoursProcessing(activate);}
void Retina::activateContoursProcessing(const bool activate){_retinaFilter->activateMovingContoursProcessing(activate);}
void Retina::activateContoursProcessing(const bool activate){_retinaFilter->activateContoursProcessing(activate);}
} // end of namespace cv
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment