{
enum { H = 0, HS = 1, HSV = 2 };
CvMeanShiftTrackerParams(int tracking_type = CvMeanShiftTrackerParams::HS,
- CvTermCriteria term_crit = CvTermCriteria())
- {
- }
+ CvTermCriteria term_crit = CvTermCriteria());
int tracking_type;
vector<float> h_range;
CvHybridTrackerParams(float ft_tracker_weight = 0.5, float ms_tracker_weight = 0.5,
CvFeatureTrackerParams ft_params = CvFeatureTrackerParams(),
CvMeanShiftTrackerParams ms_params = CvMeanShiftTrackerParams(),
- CvMotionModel model = CvMotionModel())
- {
- }
+ CvMotionModel model = CvMotionModel());
float ft_tracker_weight;
float ms_tracker_weight;
// check if the spatial constant is correct (avoid 0 value to avoid division by 0)
if (desired_k<=0)
{
- k=0.001;
+ k=0.001f;
std::cerr<<"BasicRetinaFilter::spatial constant of the low pass filter must be superior to zero !!! correcting parameter setting to 0,001"<<std::endl;
}
float _alpha = k*k;
- float _mu = 0.8;
+ float _mu = 0.8f;
unsigned int tableOffset=filterIndex*3;
if (k<=0)
{
std::cerr<<"BasicRetinaFilter::spatial filtering coefficient must be superior to zero, correcting value to 0.01"<<std::endl;
- _alpha=0.0001;
+ _alpha=0.0001f;
}
- float _temp = (1.0+_beta)/(2.0*_mu*_alpha);
- float _a = _filteringCoeficientsTable[tableOffset] = 1.0 + _temp - sqrt( (1.0+_temp)*(1.0+_temp) - 1.0);
- _filteringCoeficientsTable[1+tableOffset]=(1.0-_a)*(1.0-_a)*(1.0-_a)*(1.0-_a)/(1.0+_beta);
+ float _temp = (1+_beta)/(2*_mu*_alpha);
+ float _a = _filteringCoeficientsTable[tableOffset] = 1 + _temp - (float)sqrt( (1.0+_temp)*(1.0+_temp) - 1.0);
+ _filteringCoeficientsTable[1+tableOffset]=(1-_a)*(1-_a)*(1-_a)*(1-_a)/(1+_beta);
_filteringCoeficientsTable[2+tableOffset] =tau;
//std::cout<<"BasicRetinaFilter::normal:"<<(1.0-_a)*(1.0-_a)*(1.0-_a)*(1.0-_a)/(1.0+_beta)<<" -> old:"<<(1-_a)*(1-_a)*(1-_a)*(1-_a)/(1+_beta)<<std::endl;
}
float _beta = beta+tau;
- float _mu=0.8;
+ float _mu=0.8f;
if (alpha0<=0)
{
std::cerr<<"BasicRetinaFilter::spatial filtering coefficient must be superior to zero, correcting value to 0.01"<<std::endl;
unsigned int tableOffset=filterIndex*3;
- float _alpha=0.8;
- float _temp = (1.0+_beta)/(2.0*_mu*_alpha);
- float _a=_filteringCoeficientsTable[tableOffset] = 1.0 + _temp - sqrt( (1.0+_temp)*(1.0+_temp) - 1.0);
- _filteringCoeficientsTable[tableOffset+1]=(1.0-_a)*(1.0-_a)*(1.0-_a)*(1.0-_a)/(1.0+_beta);
+ float _alpha=0.8f;
+ float _temp = (1+_beta)/(2*_mu*_alpha);
+ float _a=_filteringCoeficientsTable[tableOffset] = 1 + _temp - (float)sqrt( (1.0+_temp)*(1.0+_temp) - 1.0);
+ _filteringCoeficientsTable[tableOffset+1]=(1-_a)*(1-_a)*(1-_a)*(1-_a)/(1+_beta);
_filteringCoeficientsTable[tableOffset+2] =tau;
- float commonFactor=alpha0/sqrt((float)(_halfNBcolumns*_halfNBcolumns+_halfNBrows*_halfNBrows)+1.0);
+ float commonFactor=alpha0/(float)sqrt(_halfNBcolumns*_halfNBcolumns+_halfNBrows*_halfNBrows+1.0);
//memset(_progressiveSpatialConstant, 255, _filterOutput.getNBpixels());
for (unsigned int idColumn=0;idColumn<_halfNBcolumns; ++idColumn)
for (unsigned int idRow=0;idRow<_halfNBrows; ++idRow)
float _beta = beta+tau;
float _alpha=k*k;
- float _mu=0.8;
+ float _mu=0.8f;
if (k<=0)
{
std::cerr<<"BasicRetinaFilter::spatial filtering coefficient must be superior to zero, correcting value to 0.01"<<std::endl;
//alpha0=0.0001;
}
unsigned int tableOffset=filterIndex*3;
- float _temp = (1.0+_beta)/(2.0*_mu*_alpha);
- float _a=_filteringCoeficientsTable[tableOffset] = 1.0 + _temp - sqrt( (1.0+_temp)*(1.0+_temp) - 1.0);
- _filteringCoeficientsTable[tableOffset+1]=(1.0-_a)*(1.0-_a)*(1.0-_a)*(1.0-_a)/(1.0+_beta);
+ float _temp = (1+_beta)/(2*_mu*_alpha);
+ float _a=_filteringCoeficientsTable[tableOffset] = 1 + _temp - (float)sqrt( (1.0+_temp)*(1.0+_temp) - 1.0);
+ _filteringCoeficientsTable[tableOffset+1]=(1-_a)*(1-_a)*(1-_a)*(1-_a)/(1+_beta);
_filteringCoeficientsTable[tableOffset+2] =tau;
//memset(_progressiveSpatialConstant, 255, _filterOutput.getNBpixels());
const float *localLuminancePTR=localLuminance;
const float *inputFramePTR=inputFrame;
float *outputFramePTR=outputFrame;
- float factor=_maxInputValue*2/CV_PI;
+ float factor=_maxInputValue*2/(float)CV_PI;
for (register unsigned int IDpixel=0 ; IDpixel<_filterOutput.getNBpixels() ; ++IDpixel, ++inputFramePTR)
{
float X0=*(localLuminancePTR++)*_localLuminanceFactor+_localLuminanceAddon;
* @param maxInputValue: the maximum amplitude value measured after local adaptation processing (c.f. function runFilter_LocalAdapdation & runFilter_LocalAdapdation_autonomous)
* @param meanLuminance: the a priori meann luminance of the input data (should be 128 for 8bits images but can vary greatly in case of High Dynamic Range Images (HDRI)
*/
- void setV0CompressionParameter(const float v0, const float maxInputValue, const float){ _v0=v0*maxInputValue; _localLuminanceFactor=v0; _localLuminanceAddon=maxInputValue*(1.0-v0); _maxInputValue=maxInputValue;};
+ void setV0CompressionParameter(const float v0, const float maxInputValue, const float){ _v0=v0*maxInputValue; _localLuminanceFactor=v0; _localLuminanceAddon=maxInputValue*(1-v0); _maxInputValue=maxInputValue;};
/**
* update local luminance adaptation setup, initial maxInputValue is kept. This function should be applied for normal local adaptation (not for tone mapping operation)
* local luminance adaptation setup, this function should be applied for normal local adaptation (not for tone mapping operation)
* @param v0: compression effect for the local luminance adaptation processing, set a value between 0.6 and 0.9 for best results, a high value yields to a high compression effect
*/
- void setV0CompressionParameter(const float v0){ _v0=v0*_maxInputValue; _localLuminanceFactor=v0; _localLuminanceAddon=_maxInputValue*(1.0-v0);};
+ void setV0CompressionParameter(const float v0){ _v0=v0*_maxInputValue; _localLuminanceFactor=v0; _localLuminanceAddon=_maxInputValue*(1-v0);};
/**
* local luminance adaptation setup, this function should be applied for local adaptation applied to tone mapping operation
prev_trackwindow = Rect(prev_trackwindow.x - r, prev_trackwindow.y - r, prev_trackwindow.x + r,
prev_trackwindow.y + r) & Rect(0, 0, cols, rows);
- prev_center.x = prev_trackwindow.x + prev_trackwindow.width / 2;
- prev_center.y = prev_trackwindow.y + prev_trackwindow.height / 2;
+ prev_center.x = (float)(prev_trackwindow.x + prev_trackwindow.width / 2);
+ prev_center.y = (float)(prev_trackwindow.y + prev_trackwindow.height / 2);
#ifdef DEBUG_HYTRACKER
ellipse(image, prev_trackbox, Scalar(0, 0, 255), 1, CV_AA);
matcher->match(prev_desc, curr_desc, matches);
- for (int i = 0; i < matches.size(); i++)
+ for (int i = 0; i < (int)matches.size(); i++)
{
prev_keys.push_back(prev_keypoints[matches[i].queryIdx].pt);
curr_keys.push_back(curr_keypoints[matches[i].trainIdx].pt);
Mat T = findHomography(prev_keys, curr_keys, CV_LMEDS);
- prev_trackwindow.x += T.at<double> (0, 2);
- prev_trackwindow.y += T.at<double> (1, 2);
+ prev_trackwindow.x += cvRound(T.at<double> (0, 2));
+ prev_trackwindow.y += cvRound(T.at<double> (1, 2));
}
prev_center.x = prev_trackwindow.x;
Point2f feature0_center(0, 0);
Point2f feature1_center(0, 0);
int goodtracks = 0;
- for (int i = 0; i < features[1].size(); i++)
+ for (int i = 0; i < (int)features[1].size(); i++)
{
if (status[i] == 1)
{
Point2f CvFeatureTracker::getTrackingCenter()
{
Point2f center(0, 0);
- center.x = prev_center.x + prev_trackwindow.width/2.0;
- center.y = prev_center.y + prev_trackwindow.height/2.0;
+ center.x = (float)(prev_center.x + prev_trackwindow.width/2.0);
+ center.y = (float)(prev_center.y + prev_trackwindow.height/2.0);
return center;
}
using namespace cv;
using namespace std;
+CvHybridTrackerParams::CvHybridTrackerParams(float _ft_tracker_weight, float _ms_tracker_weight,
+ CvFeatureTrackerParams _ft_params,
+ CvMeanShiftTrackerParams _ms_params,
+ CvMotionModel)
+{
+ ft_tracker_weight = _ft_tracker_weight;
+ ms_tracker_weight = _ms_tracker_weight;
+ ft_params = _ft_params;
+ ms_params = _ms_params;
+}
+
+CvMeanShiftTrackerParams::CvMeanShiftTrackerParams(int _tracking_type, CvTermCriteria _term_crit)
+{
+ tracking_type = _tracking_type;
+ term_crit = _term_crit;
+}
+
CvHybridTracker::CvHybridTracker() {
}
Mat hist(image.size(), CV_64F);
for (int i = 0; i < hist.rows; i++)
for (int j = 0; j < hist.cols; j++) {
- int pos = getL2Norm(Point(i, j), center);
+ int pos = cvRound(getL2Norm(Point(i, j), center));
if (pos < ksize / 2.0)
hist.at<double> (i, j) = 1.0 - (kernel.at<double> (pos) / max);
}
void CvHybridTracker::newTracker(Mat image, Rect selection) {
prev_proj = Mat::zeros(image.size(), CV_64FC1);
- prev_center = Point2f(selection.x + selection.width / 2.0, selection.y
- + selection.height / 2.0);
+ prev_center = Point2f(selection.x + selection.width / 2.0f, selection.y
+ + selection.height / 2.0f);
prev_window = selection;
mstracker->newTrackingWindow(image, selection);
double total_len = ms_len + ft_len;
params.ms_tracker_weight *= (ittr - 1);
- params.ms_tracker_weight += (ms_len / total_len);
+ params.ms_tracker_weight += (float)((ms_len / total_len));
params.ms_tracker_weight /= ittr;
params.ft_tracker_weight *= (ittr - 1);
- params.ft_tracker_weight += (ft_len / total_len);
+ params.ft_tracker_weight += (float)((ft_len / total_len));
params.ft_tracker_weight /= ittr;
circle(image, prev_center, 3, Scalar(0, 0, 0), -1, 8);
Mat ms_proj = ms_backproj.mul(ms_distproj);
float dist_err = getL2Norm(mstracker->getTrackingCenter(), fttracker->getTrackingCenter());
- Mat ft_gaussproj = getGaussianProjection(image, dist_err, -1, fttracker->getTrackingCenter());
+ Mat ft_gaussproj = getGaussianProjection(image, cvRound(dist_err), -1, fttracker->getTrackingCenter());
Mat ft_distproj = getDistanceProjection(image, fttracker->getTrackingCenter());
Mat ft_proj = ft_gaussproj.mul(ft_distproj);
Point2f ft_center = fttracker->getTrackingCenter();
float a = params.low_pass_gain;
- curr_center.x = (1.0 - a) * prev_center.x + a * (params.ms_tracker_weight * ms_track.center.x + params.ft_tracker_weight * ft_center.x);
- curr_center.y = (1.0 - a) * prev_center.y + a * (params.ms_tracker_weight * ms_track.center.y + params.ft_tracker_weight * ft_center.y);
+ curr_center.x = (1 - a) * prev_center.x + a * (params.ms_tracker_weight * ms_track.center.x + params.ft_tracker_weight * ft_center.x);
+ curr_center.y = (1 - a) * prev_center.y + a * (params.ms_tracker_weight * ms_track.center.y + params.ft_tracker_weight * ft_center.y);
}
Rect CvHybridTracker::getTrackingWindow() {
#endif
// setup progressive prefilter that will be applied BEFORE log sampling
- setProgressiveFilterConstants_CentredAccuracy(0.0, 0.0, 0.99);
+ setProgressiveFilterConstants_CentredAccuracy(0.f, 0.f, 0.99f);
// (re)create the image output buffer and transform table if the reduction factor changed
_sampledFrame.resize(_outputNBpixels*(1+(unsigned int)_colorModeCapable*2));
#endif
// setup progressive prefilter that will be applied BEFORE log sampling
- setProgressiveFilterConstants_CentredAccuracy(0.0, 0.0, 0.99);
+ setProgressiveFilterConstants_CentredAccuracy(0.f, 0.f, 0.99f);
// (re)create the image output buffer and transform table if the reduction factor changed
_sampledFrame.resize(_outputNBpixels*(1+(unsigned int)_colorModeCapable*2));
void MagnoRetinaFilter::setCoefficientsTable(const float parasolCells_beta, const float parasolCells_tau, const float parasolCells_k, const float amacrinCellsTemporalCutFrequency, const float localAdaptIntegration_tau, const float localAdaptIntegration_k )
{
- _temporalCoefficient=exp(-1.0/amacrinCellsTemporalCutFrequency);
+ _temporalCoefficient=(float)exp(-1.0/amacrinCellsTemporalCutFrequency);
// the first set of parameters is dedicated to the low pass filtering property of the ganglion cells
BasicRetinaFilter::setLPfilterParameters(parasolCells_beta, parasolCells_tau, parasolCells_k, 0);
// the second set of parameters is dedicated to the ganglion cells output intergartion for their local adaptation property
// ON and OFF channels writing step
*(parvocellularOutputON_PTR++)=*(bipolarCellsON_PTR++) = isPositive*pixelDifference;
- *(parvocellularOutputOFF_PTR++)=*(bipolarCellsOFF_PTR++)= (isPositive-1.0)*pixelDifference;
+ *(parvocellularOutputOFF_PTR++)=*(bipolarCellsOFF_PTR++)= (isPositive-1)*pixelDifference;
}
}
}
}
// original API level data accessors
-void Retina::getMagno(std::valarray<float> &retinaOutput_magno){_retinaFilter->getMovingContours();}
-void Retina::getParvo(std::valarray<float> &retinaOutput_parvo){_retinaFilter->getContours();}
+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 parametersSaveFile, const cv::Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
// init static values
static float _LMStoACr1Cr2[]={1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -0.5, -0.5, 1.0};
//static double _ACr1Cr2toLMS[]={0.5, 0.5, 0.0, 0.5, -0.5, 0.0, 0.5, 0.0, 1.0};
-static float _LMStoLab[]={0.5774, 0.5774, 0.5774, 0.4082, 0.4082, -0.8165, 0.7071, -0.7071, 0.0};
+static float _LMStoLab[]={0.5774f, 0.5774f, 0.5774f, 0.4082f, 0.4082f, -0.8165f, 0.7071f, -0.7071f, 0.f};
// constructor/desctructor
RetinaColor::RetinaColor(const unsigned int NBrows, const unsigned int NBcolumns, const RETINA_COLORSAMPLINGMETHOD samplingMethod)
// set default spatio-temporal filter parameters
setLPfilterParameters(0.0, 0.0, 1.5);
setLPfilterParameters(0.0, 0.0, 10.5, 1);// for the low pass filter dedicated to contours energy extraction (demultiplexing process)
- setLPfilterParameters(0.0, 0.0, 0.9, 2);
+ setLPfilterParameters(0.f, 0.f, 0.9f, 2);
// init default value on image Gradient
- _imageGradient=0.57;
+ _imageGradient=0.57f;
// init color sampling map
_initColorSampling();
{
// filling the conversion table for multiplexed <=> demultiplexed frame
- srand(time(NULL));
+ srand((unsigned)time(NULL));
// preInit cones probabilities
_pR=_pB=_pG=0;
{
_colorSampling[index] = index+((index%3+(index%_filterOutput.getNBcolumns()))%3)*_filterOutput.getNBpixels();
}
- _pR=_pB=_pG=1.0/3.0;
+ _pR=_pB=_pG=1.f/3;
break;
case RETINA_COLOR_BAYER: // default sets bayer sampling
for (unsigned int index=0 ; index<_filterOutput.getNBpixels(); ++index)
unsigned int maxNBpixels=3*_filterOutput.getNBpixels();
register float *colorLocalDensityPTR=&_colorLocalDensity[0];
for (unsigned int i=0;i<maxNBpixels;++i, ++colorLocalDensityPTR)
- *colorLocalDensityPTR=1.0/ *colorLocalDensityPTR;
+ *colorLocalDensityPTR=1.f/ *colorLocalDensityPTR;
#ifdef RETINACOLORDEBUG
std::cout<<"INIT _colorLocalDensity max, min: "<<_colorLocalDensity.max()<<", "<<_colorLocalDensity.min()<<std::endl;
for (unsigned int indexc=1 ; indexc<_filterOutput.getNBcolumns()-1; ++indexc)
{
unsigned int index=indexc+indexr*_filterOutput.getNBcolumns();
- inputOutputBuffer[index]=(inputOutputBuffer[index-1]+inputOutputBuffer[index]+inputOutputBuffer[index+1])/3.0;
+ inputOutputBuffer[index]=(inputOutputBuffer[index-1]+inputOutputBuffer[index]+inputOutputBuffer[index+1])/3.f;
}
}
for (unsigned int indexc=0 ; indexc<_filterOutput.getNBcolumns(); ++indexc)
for (unsigned int indexr=1 ; indexr<_filterOutput.getNBrows()-1; ++indexr)
{
unsigned int index=indexc+indexr*_filterOutput.getNBcolumns();
- inputOutputBuffer[index]=(inputOutputBuffer[index-_filterOutput.getNBcolumns()]+inputOutputBuffer[index]+inputOutputBuffer[index+_filterOutput.getNBcolumns()])/3.0;
+ inputOutputBuffer[index]=(inputOutputBuffer[index-_filterOutput.getNBcolumns()]+inputOutputBuffer[index]+inputOutputBuffer[index+_filterOutput.getNBcolumns()])/3.f;
}
}
}
{
unsigned int indexR=indexc+indexr*_filterOutput.getNBcolumns();
unsigned int indexB=_filterOutput.getDoubleNBpixels()+indexc+1+(indexr+1)*_filterOutput.getNBcolumns();
- inputOutputBuffer[indexR]=(inputOutputBuffer[indexR-1]+inputOutputBuffer[indexR+1])/2.0;
- inputOutputBuffer[indexB]=(inputOutputBuffer[indexB-1]+inputOutputBuffer[indexB+1])/2.0;
+ inputOutputBuffer[indexR]=(inputOutputBuffer[indexR-1]+inputOutputBuffer[indexR+1])/2.f;
+ inputOutputBuffer[indexB]=(inputOutputBuffer[indexB-1]+inputOutputBuffer[indexB+1])/2.f;
}
}
for (unsigned int indexr=1 ; indexr<_filterOutput.getNBrows()-1; indexr+=2)
{
unsigned int indexR=indexc+indexr*_filterOutput.getNBcolumns();
unsigned int indexB=_filterOutput.getDoubleNBpixels()+indexc+1+(indexr+1)*_filterOutput.getNBcolumns();
- inputOutputBuffer[indexR]=(inputOutputBuffer[indexR-_filterOutput.getNBcolumns()]+inputOutputBuffer[indexR+_filterOutput.getNBcolumns()])/2.0;
- inputOutputBuffer[indexB]=(inputOutputBuffer[indexB-_filterOutput.getNBcolumns()]+inputOutputBuffer[indexB+_filterOutput.getNBcolumns()])/2.0;
+ inputOutputBuffer[indexR]=(inputOutputBuffer[indexR-_filterOutput.getNBcolumns()]+inputOutputBuffer[indexR+_filterOutput.getNBcolumns()])/2.f;
+ inputOutputBuffer[indexB]=(inputOutputBuffer[indexB-_filterOutput.getNBcolumns()]+inputOutputBuffer[indexB+_filterOutput.getNBcolumns()])/2.f;
}
}
for (unsigned int indexc=0 ; indexc<_filterOutput.getNBcolumns(); indexc+=2)
{
unsigned int indexG=_filterOutput.getNBpixels()+indexc+(indexr)*_filterOutput.getNBcolumns()+indexr%2;
- inputOutputBuffer[indexG]=(inputOutputBuffer[indexG-1]+inputOutputBuffer[indexG+1]+inputOutputBuffer[indexG-_filterOutput.getNBcolumns()]+inputOutputBuffer[indexG+_filterOutput.getNBcolumns()])*0.25;
+ inputOutputBuffer[indexG]=(inputOutputBuffer[indexG-1]+inputOutputBuffer[indexG+1]+inputOutputBuffer[indexG-_filterOutput.getNBcolumns()]+inputOutputBuffer[indexG+_filterOutput.getNBcolumns()])*0.25f;
}
}
for (unsigned int indexc=1 ; indexc<_filterOutput.getNBcolumns()-1; ++indexc)
{
unsigned int index=indexc+indexr*_filterOutput.getNBcolumns();
- _tempMultiplexedFrame[index]=(4.0*sourceBuffer[index]+sourceBuffer[index-1-_filterOutput.getNBcolumns()]+sourceBuffer[index-1+_filterOutput.getNBcolumns()]+sourceBuffer[index+1-_filterOutput.getNBcolumns()]+sourceBuffer[index+1+_filterOutput.getNBcolumns()])*0.125;
+ _tempMultiplexedFrame[index]=(4.f*sourceBuffer[index]+sourceBuffer[index-1-_filterOutput.getNBcolumns()]+sourceBuffer[index-1+_filterOutput.getNBcolumns()]+sourceBuffer[index+1-_filterOutput.getNBcolumns()]+sourceBuffer[index+1+_filterOutput.getNBcolumns()])*0.125f;
}
}
memcpy(destinationBuffer, &_tempMultiplexedFrame[0], sizeof(float)*_filterOutput.getNBpixels());
void RetinaColor::_getNormalizedContoursImage(const float *inputFrame, float *outputFrame)
{
float maxValue=0;
- float normalisationFactor=1.0/3.0;
+ float normalisationFactor=1.f/3;
for (unsigned int indexr=1 ; indexr<_filterOutput.getNBrows()-1; ++indexr)
{
for (unsigned int indexc=1 ; indexc<_filterOutput.getNBcolumns()-1; ++indexc)
{
unsigned int index=indexc+indexr*_filterOutput.getNBcolumns();
- outputFrame[index]=normalisationFactor*fabs(8.0*inputFrame[index]-inputFrame[index-1]-inputFrame[index+1]-inputFrame[index-_filterOutput.getNBcolumns()]-inputFrame[index+_filterOutput.getNBcolumns()]-inputFrame[index-1-_filterOutput.getNBcolumns()]-inputFrame[index-1+_filterOutput.getNBcolumns()]-inputFrame[index+1-_filterOutput.getNBcolumns()]-inputFrame[index+1+_filterOutput.getNBcolumns()]);
+ outputFrame[index]=normalisationFactor*fabs(8.f*inputFrame[index]-inputFrame[index-1]-inputFrame[index+1]-inputFrame[index-_filterOutput.getNBcolumns()]-inputFrame[index+_filterOutput.getNBcolumns()]-inputFrame[index-1-_filterOutput.getNBcolumns()]-inputFrame[index-1+_filterOutput.getNBcolumns()]-inputFrame[index+1-_filterOutput.getNBcolumns()]-inputFrame[index+1+_filterOutput.getNBcolumns()]);
if (outputFrame[index]>maxValue)
maxValue=outputFrame[index];
}
}
- normalisationFactor=1.0/maxValue;
+ normalisationFactor=1.f/maxValue;
// normalisation [0, 1]
- for (unsigned int indexp=1 ; indexp<_filterOutput.getNBrows()-1; ++indexp)
- outputFrame[indexp]=outputFrame[indexp]*normalisationFactor;
+ for (unsigned int indexp=1 ; indexp<_filterOutput.getNBrows()-1; ++indexp)
+ outputFrame[indexp]=outputFrame[indexp]*normalisationFactor;
}
//////////////////////////////////////////////////////////
{
/**********/
- _gain = (1-0.57)*(1-0.57)*(1-0.06)*(1-0.06);
+ _gain = (1-0.57f)*(1-0.57f)*(1-0.06f)*(1-0.06f);
// launch the serie of 1D directional filters in order to compute the 2D low pass filter
_adaptiveHorizontalCausalFilter_addInput(inputFrame, outputFrame, 0, _filterOutput.getNBrows());
const float verticalGrad_n=fabs(luminance[pixelIndex+2*_filterOutput.getNBcolumns()]-luminance[pixelIndex]);
const float horizontalGrad_n=fabs(luminance[pixelIndex+2]-luminance[pixelIndex]);
- const float horizontalGradient=0.5*horizontalGrad+0.25*(horizontalGrad_p+horizontalGrad_n);
- const float verticalGradient=0.5*verticalGrad+0.25*(verticalGrad_p+verticalGrad_n);
+ const float horizontalGradient=0.5f*horizontalGrad+0.25f*(horizontalGrad_p+horizontalGrad_n);
+ const float verticalGradient=0.5f*verticalGrad+0.25f*(verticalGrad_p+verticalGrad_n);
// compare local gradient means and fill the appropriate filtering coefficient value that will be used in adaptative filters
if (horizontalGradient<verticalGradient)
{
- _imageGradient[pixelIndex+_filterOutput.getNBpixels()]=0.06;
- _imageGradient[pixelIndex]=0.57;
+ _imageGradient[pixelIndex+_filterOutput.getNBpixels()]=0.06f;
+ _imageGradient[pixelIndex]=0.57f;
}
else
{
- _imageGradient[pixelIndex+_filterOutput.getNBpixels()]=0.57;
- _imageGradient[pixelIndex]=0.06;
+ _imageGradient[pixelIndex+_filterOutput.getNBpixels()]=0.57f;
+ _imageGradient[pixelIndex]=0.06f;
}
}
}
// fill _hybridParvoMagnoCoefTable
int i, j, halfRows=_photoreceptorsPrefilter.getNBrows()/2, halfColumns=_photoreceptorsPrefilter.getNBcolumns()/2;
float *hybridParvoMagnoCoefTablePTR= &_retinaParvoMagnoMapCoefTable[0];
- float minDistance=(float)MIN(halfRows, halfColumns)*0.7;
+ float minDistance=MIN(halfRows, halfColumns)*0.7f;
for (i=0;i<(int)_photoreceptorsPrefilter.getNBrows();++i)
{
for (j=0;j<(int)_photoreceptorsPrefilter.getNBcolumns();++j)
float distanceToCenter=sqrt(((float)(i-halfRows)*(i-halfRows)+(j-halfColumns)*(j-halfColumns)));
if (distanceToCenter<minDistance)
{
- float a=*(hybridParvoMagnoCoefTablePTR++)=0.5+0.5*cos(CV_PI*distanceToCenter/minDistance);
- *(hybridParvoMagnoCoefTablePTR++)=1.0-a;
+ float a=*(hybridParvoMagnoCoefTablePTR++)=0.5f+0.5f*(float)cos(CV_PI*distanceToCenter/minDistance);
+ *(hybridParvoMagnoCoefTablePTR++)=1-a;
}else
{
*(hybridParvoMagnoCoefTablePTR++)=0;
- *(hybridParvoMagnoCoefTablePTR++)=1.0;
+ *(hybridParvoMagnoCoefTablePTR++)=1.f;
}
}
}
_normalizeParvoOutput_0_maxOutputValue=normalizeParvoOutput_0_maxOutputValue;
_normalizeMagnoOutput_0_maxOutputValue=normalizeMagnoOutput_0_maxOutputValue;
_maxOutputValue=maxOutputValue;
- _photoreceptorsPrefilter.setV0CompressionParameter(0.9, maxInputValue, meanValue);
+ _photoreceptorsPrefilter.setV0CompressionParameter(0.9f, 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, 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)
//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.setV0CompressionParameter(0.9, maxInputValue, meanValue);
- _MagnoRetinaFilter.setCoefficientsTable(LPfilterGain, LPfilterTemporalresponse, LPfilterSpatialResponse, MovingContoursExtractorCoefficient, 0, 2.0*LPfilterSpatialResponse);
- _MagnoRetinaFilter.setV0CompressionParameter(0.7, maxInputValue, meanValue);
+ _ParvoRetinaFilter.setV0CompressionParameter(0.9f, maxInputValue, meanValue);
+ _MagnoRetinaFilter.setCoefficientsTable(LPfilterGain, LPfilterTemporalresponse, LPfilterSpatialResponse, MovingContoursExtractorCoefficient, 0, 2*LPfilterSpatialResponse);
+ _MagnoRetinaFilter.setV0CompressionParameter(0.7f, maxInputValue, meanValue);
// stability controls value init
_setInitPeriodCount();
* setup the local luminance adaptation capability
* @param V0CompressionParameter: the compression strengh of the photoreceptors local adaptation output, set a value between 160 and 250 for best results, a high value increases more the low value sensitivity... and the output saturates faster, recommended value: 160
*/
- inline void setPhotoreceptorsLocalAdaptationSensitivity(const float V0CompressionParameter){_photoreceptorsPrefilter.setV0CompressionParameter(1.0-V0CompressionParameter);_setInitPeriodCount();};
+ inline void setPhotoreceptorsLocalAdaptationSensitivity(const float V0CompressionParameter){_photoreceptorsPrefilter.setV0CompressionParameter(1-V0CompressionParameter);_setInitPeriodCount();};
/**
* setup the local luminance adaptation capability
* @param projectedRadiusLength: the distance to image center in the retina log sampled space
* @return the distance to image center in the input image space
*/
- inline const float getRetinaSamplingBackProjection(const float projectedRadiusLength){if (_photoreceptorsLogSampling)return _photoreceptorsLogSampling->getOriginalRadiusLength(projectedRadiusLength);else return projectedRadiusLength;};
+ inline const float getRetinaSamplingBackProjection(const float projectedRadiusLength)
+ {
+ if (_photoreceptorsLogSampling)
+ return (float)_photoreceptorsLogSampling->getOriginalRadiusLength(projectedRadiusLength);
+ return projectedRadiusLength;
+ };
/////////////////:
// retina dimensions getters
// change the range of the data to 0->255
type factor = maxOutputValue/(maxValue-minValue);
- type offset = -1.0*minValue*factor;
+ type offset = (type)(-minValue*factor);
inputOutputBufferPTR=inputOutputBuffer;
for (register size_t j = 0; j < processedPixels; ++j, ++inputOutputBufferPTR)
#endif
#elif defined WIN32 || defined _WIN32
- #include <intrin.h>
- #define CV_XADD(addr,delta) _InterlockedExchangeAdd((long volatile*)(addr), (delta))
+ #define WIN32_MEAN_AND_LEAN
+ #include <windows.h>
+ #undef min
+ #undef max
+ #undef abs
+ #define CV_XADD(addr,delta) InterlockedExchangeAdd((long volatile*)(addr), (delta))
#else
template<typename _Tp> static inline _Tp CV_XADD(_Tp* addr, _Tp delta)
*/
inline std::ostream& operator <<(std::ostream& out, const LshStats& stats)
{
- size_t w = 20;
+ int w = 20;
out << "Lsh Table Stats:\n" << std::setw(w) << std::setiosflags(std::ios::right) << "N buckets : "
<< stats.n_buckets_ << "\n" << std::setw(w) << std::setiosflags(std::ios::right) << "mean size : "
<< std::setiosflags(std::ios::left) << stats.bucket_size_mean_ << "\n" << std::setw(w)
void initialize(size_t key_size)
{
speed_level_ = kHash;
- key_size_ = key_size;
+ key_size_ = (unsigned)key_size;
}
/** Optimize the table for speed/space
declare.in(src_host, WARMUP_RNG);\r
\r
GpuMat src(src_host);\r
- int dst;\r
+ int dst=0;\r
GpuMat buf;\r
\r
declare.time(0.5).iterations(100);\r
void callBack_rescaleGrayLevelMat(int, void*)
{
std::cout<<"Histogram clipping value changed, current value = "<<histogramClippingValue<<std::endl;
- rescaleGrayLevelMat(inputImage, imageInputRescaled, (float)histogramClippingValue/100.0);
+ rescaleGrayLevelMat(inputImage, imageInputRescaled, (float)(histogramClippingValue/100.0));
normalize(imageInputRescaled, imageInputRescaled, 0.0, 255.0, cv::NORM_MINMAX);
}
void callBack_updateRetinaParams(int, void*)
{
- retina->setupOPLandIPLParvoChannel(true, true, (double)localAdaptation_photoreceptors/200.0, 0.5, 0.43, (double)retinaHcellsGain, 1.0, 7.0, (double)localAdaptation_Gcells/200.0);
+ retina->setupOPLandIPLParvoChannel(true, true, (float)(localAdaptation_photoreceptors/200.0), 0.5f, 0.43f, (double)retinaHcellsGain, 1.f, 7.f, (float)(localAdaptation_Gcells/200.0));
}
int colorSaturationFactor;
void callback_saturateColors(int, void*)
{
- retina->setColorSaturation((double)colorSaturationFactor/10.0);
+ retina->setColorSaturation(true, colorSaturationFactor/10.0f);
}
int main(int argc, char* argv[]) {
/////////////////////////////////////////////
// apply default parameters of user interaction variables
rescaleGrayLevelMat(inputImage, imageInputRescaled, (float)histogramClippingValue/100);
- retina->setColorSaturation(true,colorSaturationFactor);
+ retina->setColorSaturation(true,(float)colorSaturationFactor);
callBack_updateRetinaParams(1,NULL); // first call for default parameters setup
// processing loop with stop condition