fixed multiple warnings on Windows. fixed bug #1368

pull/13383/head
Vadim Pisarevsky 13 years ago
parent 78e678b1f8
commit 60ebe2003f
  1. 8
      modules/contrib/include/opencv2/contrib/hybridtracker.hpp
  2. 34
      modules/contrib/src/basicretinafilter.cpp
  3. 4
      modules/contrib/src/basicretinafilter.hpp
  4. 4
      modules/contrib/src/colortracker.cpp
  5. 12
      modules/contrib/src/featuretracker.cpp
  6. 33
      modules/contrib/src/hybridtracker.cpp
  7. 4
      modules/contrib/src/imagelogpolprojection.cpp
  8. 2
      modules/contrib/src/magnoretinafilter.cpp
  9. 2
      modules/contrib/src/parvoretinafilter.cpp
  10. 4
      modules/contrib/src/retina.cpp
  11. 52
      modules/contrib/src/retinacolor.cpp
  12. 16
      modules/contrib/src/retinafilter.cpp
  13. 9
      modules/contrib/src/retinafilter.hpp
  14. 2
      modules/contrib/src/templatebuffer.hpp
  15. 8
      modules/core/include/opencv2/core/operations.hpp
  16. 4
      modules/flann/include/opencv2/flann/lsh_table.h
  17. 2
      modules/gpu/perf/perf_arithm.cpp
  18. 8
      samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp

@ -74,9 +74,7 @@ struct CV_EXPORTS CvMeanShiftTrackerParams
{
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;
@ -105,9 +103,7 @@ struct CV_EXPORTS CvHybridTrackerParams
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;

@ -166,22 +166,22 @@ void BasicRetinaFilter::setLPfilterParameters(const float beta, const float tau,
// 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;
@ -199,7 +199,7 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CentredAccuracy(const floa
}
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;
@ -208,13 +208,13 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CentredAccuracy(const floa
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)
@ -258,16 +258,16 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CustomAccuracy(const float
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());
@ -345,7 +345,7 @@ void BasicRetinaFilter::_localLuminanceAdaptationPosNegValues(const float *input
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;

@ -267,7 +267,7 @@ public:
* @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)
@ -280,7 +280,7 @@ public:
* 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

@ -97,8 +97,8 @@ RotatedRect CvMeanShiftTracker::updateTrackingWindow(Mat image)
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);

@ -124,7 +124,7 @@ Rect CvFeatureTracker::updateTrackingWindowWithSIFT(Mat image)
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);
@ -132,8 +132,8 @@ Rect CvFeatureTracker::updateTrackingWindowWithSIFT(Mat image)
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;
@ -171,7 +171,7 @@ Rect CvFeatureTracker::updateTrackingWindowWithFlow(Mat image)
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)
{
@ -213,8 +213,8 @@ Rect CvFeatureTracker::getTrackingWindow()
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;
}

@ -45,6 +45,23 @@
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() {
}
@ -98,7 +115,7 @@ Mat CvHybridTracker::getGaussianProjection(Mat image, int ksize, double sigma,
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);
}
@ -108,8 +125,8 @@ Mat CvHybridTracker::getGaussianProjection(Mat image, int ksize, double sigma,
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);
@ -160,10 +177,10 @@ void CvHybridTracker::updateTracker(Mat image) {
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);
@ -183,7 +200,7 @@ void CvHybridTracker::updateTrackerWithEM(Mat image) {
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);
@ -215,8 +232,8 @@ void CvHybridTracker::updateTrackerWithLowPassFilter(Mat image) {
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() {

@ -177,7 +177,7 @@ bool ImageLogPolProjection::_initLogRetinaSampling(const double reductionFactor,
#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));
@ -338,7 +338,7 @@ bool ImageLogPolProjection::_initLogPolarCortexSampling(const double reductionFa
#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));

@ -144,7 +144,7 @@ void MagnoRetinaFilter::resize(const unsigned int NBrows, const unsigned int NBc
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

@ -220,7 +220,7 @@ void ParvoRetinaFilter::_OPL_OnOffWaysComputing()
// 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;
}
}
}

@ -299,8 +299,8 @@ void Retina::getMagno(cv::Mat &retinaOutput_magno)
}
// 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)

@ -77,7 +77,7 @@ namespace cv
// 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)
@ -103,10 +103,10 @@ RetinaColor::RetinaColor(const unsigned int NBrows, const unsigned int NBcolumns
// 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();
@ -167,7 +167,7 @@ void RetinaColor::_initColorSampling()
{
// filling the conversion table for multiplexed <=> demultiplexed frame
srand(time(NULL));
srand((unsigned)time(NULL));
// preInit cones probabilities
_pR=_pB=_pG=0;
@ -206,7 +206,7 @@ void RetinaColor::_initColorSampling()
{
_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)
@ -240,7 +240,7 @@ void RetinaColor::_initColorSampling()
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;
@ -476,7 +476,7 @@ void RetinaColor::_interpolateSingleChannelImage111(float *inputOutputBuffer)
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)
@ -484,7 +484,7 @@ void RetinaColor::_interpolateSingleChannelImage111(float *inputOutputBuffer)
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;
}
}
}
@ -497,8 +497,8 @@ void RetinaColor::_interpolateBayerRGBchannels(float *inputOutputBuffer)
{
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)
@ -507,8 +507,8 @@ void RetinaColor::_interpolateBayerRGBchannels(float *inputOutputBuffer)
{
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;
}
}
@ -516,7 +516,7 @@ void RetinaColor::_interpolateBayerRGBchannels(float *inputOutputBuffer)
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;
}
}
@ -527,7 +527,7 @@ void RetinaColor::_applyRIFfilter(const float *sourceBuffer, float *destinationB
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());
@ -536,21 +536,21 @@ void RetinaColor::_applyRIFfilter(const float *sourceBuffer, float *destinationB
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;
}
//////////////////////////////////////////////////////////
@ -561,7 +561,7 @@ void RetinaColor::_adaptiveSpatialLPfilter(const float *inputFrame, float *outpu
{
/**********/
_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());
@ -669,19 +669,19 @@ void RetinaColor::_computeGradient(const float *luminance)
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;
}
}
}

@ -201,7 +201,7 @@ namespace cv
// 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)
@ -209,12 +209,12 @@ namespace cv
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;
}
}
}
@ -226,15 +226,15 @@ namespace cv
_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();

@ -221,7 +221,7 @@ public:
* 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
@ -457,7 +457,12 @@ public:
* @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

@ -405,7 +405,7 @@ void TemplateBuffer<type>::normalizeGrayOutput_0_maxOutputValue(type *inputOutpu
// 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)

@ -73,8 +73,12 @@
#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)

@ -95,7 +95,7 @@ struct LshStats
*/
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)
@ -257,7 +257,7 @@ private:
void initialize(size_t key_size)
{
speed_level_ = kHash;
key_size_ = key_size;
key_size_ = (unsigned)key_size;
}
/** Optimize the table for speed/space

@ -673,7 +673,7 @@ PERF_TEST_P(DevInfo_Size_MatType, countNonZero, testing::Combine(testing::Values
declare.in(src_host, WARMUP_RNG);
GpuMat src(src_host);
int dst;
int dst=0;
GpuMat buf;
declare.time(0.5).iterations(100);

@ -122,7 +122,7 @@ void drawPlot(const cv::Mat curve, const std::string figureTitle, const int lowe
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);
}
@ -132,13 +132,13 @@ void drawPlot(const cv::Mat curve, const std::string figureTitle, const int lowe
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[]) {
@ -244,7 +244,7 @@ void drawPlot(const cv::Mat curve, const std::string figureTitle, const int lowe
/////////////////////////////////////////////
// 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

Loading…
Cancel
Save