made retina code compile with VS2005/VS2008
authorVadim Pisarevsky <no@email>
Fri, 12 Aug 2011 11:28:17 +0000 (11:28 +0000)
committerVadim Pisarevsky <no@email>
Fri, 12 Aug 2011 11:28:17 +0000 (11:28 +0000)
modules/contrib/src/basicretinafilter.cpp
modules/contrib/src/basicretinafilter.hpp
modules/contrib/src/imagelogpolprojection.cpp
modules/contrib/src/magnoretinafilter.cpp
modules/contrib/src/parvoretinafilter.cpp
modules/contrib/src/precomp.hpp
modules/contrib/src/retina.cpp
modules/contrib/src/retinacolor.cpp
modules/contrib/src/retinafilter.cpp
modules/contrib/src/templatebuffer.hpp

index d3ba9fb..f836bca 100644 (file)
@@ -295,26 +295,26 @@ void BasicRetinaFilter::setProgressiveFilterConstants_CustomAccuracy(const doubl
 // run local adaptation filter and save result in _filterOutput
 const std::valarray<double> &BasicRetinaFilter::runFilter_LocalAdapdation(const std::valarray<double> &inputFrame, const std::valarray<double> &localLuminance)
 {
-       _localLuminanceAdaptation(&inputFrame[0], &localLuminance[0], &_filterOutput[0]);
+       _localLuminanceAdaptation(get_data(inputFrame), get_data(localLuminance), &_filterOutput[0]);
        return _filterOutput;
 }
 // run local adaptation filter at a specific output adress
 void BasicRetinaFilter::runFilter_LocalAdapdation(const std::valarray<double> &inputFrame, const std::valarray<double> &localLuminance, std::valarray<double> &outputFrame)
 {
-       _localLuminanceAdaptation(&inputFrame[0], &localLuminance[0], &outputFrame[0]);
+       _localLuminanceAdaptation(get_data(inputFrame), get_data(localLuminance), &outputFrame[0]);
 }
 // run local adaptation filter and save result in _filterOutput with autonomous low pass filtering before adaptation
 const std::valarray<double> &BasicRetinaFilter::runFilter_LocalAdapdation_autonomous(const std::valarray<double> &inputFrame)
 {
-       _spatiotemporalLPfilter(&inputFrame[0], &_filterOutput[0]);
-       _localLuminanceAdaptation(&inputFrame[0], &_filterOutput[0], &_filterOutput[0]);
+       _spatiotemporalLPfilter(get_data(inputFrame), &_filterOutput[0]);
+       _localLuminanceAdaptation(get_data(inputFrame), &_filterOutput[0], &_filterOutput[0]);
        return _filterOutput;
 }
 // run local adaptation filter at a specific output adress with autonomous low pass filtering before adaptation
 void BasicRetinaFilter::runFilter_LocalAdapdation_autonomous(const std::valarray<double> &inputFrame, std::valarray<double> &outputFrame)
 {
-       _spatiotemporalLPfilter(&inputFrame[0], &_filterOutput[0]);
-       _localLuminanceAdaptation(&inputFrame[0], &_filterOutput[0], &outputFrame[0]);
+       _spatiotemporalLPfilter(get_data(inputFrame), &_filterOutput[0]);
+       _localLuminanceAdaptation(get_data(inputFrame), &_filterOutput[0], &outputFrame[0]);
 }
 // local luminance adaptation of the input in regard of localLuminance buffer
 void BasicRetinaFilter::_localLuminanceAdaptation(const double *inputFrame, const double *localLuminance, double *outputFrame)
@@ -380,14 +380,14 @@ void BasicRetinaFilter::_localLuminanceAdaptation(double *inputOutputFrame, cons
 // run LP filter and save result in the basic retina element buffer
 const std::valarray<double> &BasicRetinaFilter::runFilter_LPfilter(const std::valarray<double> &inputFrame, const unsigned int filterIndex)
 {
-       _spatiotemporalLPfilter(&inputFrame[0], &_filterOutput[0], filterIndex);
+       _spatiotemporalLPfilter(get_data(inputFrame), &_filterOutput[0], filterIndex);
        return _filterOutput;
 }
 
 // run LP filter for a new frame input and save result at a specific output adress
 void BasicRetinaFilter::runFilter_LPfilter(const std::valarray<double> &inputFrame, std::valarray<double> &outputFrame, const unsigned int filterIndex)
 {
-       _spatiotemporalLPfilter(&inputFrame[0], &outputFrame[0], filterIndex);
+       _spatiotemporalLPfilter(get_data(inputFrame), &outputFrame[0], filterIndex);
 }
 
 // run LP filter on the input data and rewrite it
index fd844e9..e13035e 100644 (file)
@@ -156,7 +156,7 @@ public:
        * forbiden method inherited from parent std::valarray
        * prefer not to use this method since the filter matrix become vectors
        */
-       void resize(const unsigned int NBpixels){std::cerr<<"error, not accessible method"<<std::endl;};
+       void resize(const unsigned int){std::cerr<<"error, not accessible method"<<std::endl;};
 
        /**
        *  low pass filter call and run (models the homogeneous cells network at the retina level, for example horizontal cells or photoreceptors)
@@ -225,7 +225,10 @@ public:
        * @param outputFrame: the output buffer in which the result is writen
        * @param filterIndex: the index which specifies the parameter set that should be used for the filtering
        */
-       inline void runProgressiveFilter(const std::valarray<double> &inputFrame, std::valarray<double> &outputFrame, const unsigned int filterIndex=0){_spatiotemporalLPfilter_Irregular(&inputFrame[0], &outputFrame[0], filterIndex);};
+       inline void runProgressiveFilter(const std::valarray<double> &inputFrame,
+                                                                        std::valarray<double> &outputFrame,
+                                                                        const unsigned int filterIndex=0)
+       {_spatiotemporalLPfilter_Irregular(get_data(inputFrame), &outputFrame[0], filterIndex);};
 
        /**
        * first order spatio-temporal low pass filter setup function
@@ -261,7 +264,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 double v0, const double maxInputValue, const double meanLuminance){ _v0=v0*maxInputValue; _localLuminanceFactor=v0; _localLuminanceAddon=maxInputValue*(1.0-v0); _maxInputValue=maxInputValue;};
+       void setV0CompressionParameter(const double v0, const double maxInputValue, const double){ _v0=v0*maxInputValue; _localLuminanceFactor=v0; _localLuminanceAddon=maxInputValue*(1.0-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)
index cc15090..206b95f 100644 (file)
@@ -300,7 +300,7 @@ bool ImageLogPolProjection::_initLogRetinaSampling(const double reductionFactor,
        return _initOK;
 }
 
-bool ImageLogPolProjection::_initLogPolarCortexSampling(const double reductionFactor, const double samplingStrenght)
+bool ImageLogPolProjection::_initLogPolarCortexSampling(const double reductionFactor, const double)
 {
        _initOK=false;
 
@@ -399,13 +399,13 @@ std::valarray<double> &ImageLogPolProjection::runProjection(const std::valarray<
        if (_colorModeCapable&&colorMode)
        {
                // progressive filtering and storage of the result in _tempBuffer
-               _spatiotemporalLPfilter_Irregular(&inputFrame[0], &_irregularLPfilteredFrame[0]);
+               _spatiotemporalLPfilter_Irregular(get_data(inputFrame), &_irregularLPfilteredFrame[0]);
                _spatiotemporalLPfilter_Irregular(&_irregularLPfilteredFrame[0], &_tempBuffer[0]); // warning, temporal issue may occur, if the temporal constant is not NULL !!!
 
-               _spatiotemporalLPfilter_Irregular(&inputFrame[0]+_filterOutput.getNBpixels(), &_irregularLPfilteredFrame[0]);
+               _spatiotemporalLPfilter_Irregular(get_data(inputFrame)+_filterOutput.getNBpixels(), &_irregularLPfilteredFrame[0]);
                _spatiotemporalLPfilter_Irregular(&_irregularLPfilteredFrame[0], &_tempBuffer[0]+_filterOutput.getNBpixels());
 
-               _spatiotemporalLPfilter_Irregular(&inputFrame[0]+_filterOutput.getNBpixels()*2, &_irregularLPfilteredFrame[0]);
+               _spatiotemporalLPfilter_Irregular(get_data(inputFrame)+_filterOutput.getNBpixels()*2, &_irregularLPfilteredFrame[0]);
                _spatiotemporalLPfilter_Irregular(&_irregularLPfilteredFrame[0], &_tempBuffer[0]+_filterOutput.getNBpixels()*2);
 
                // applying image projection/resampling
@@ -426,7 +426,7 @@ std::valarray<double> &ImageLogPolProjection::runProjection(const std::valarray<
                //normalizeGrayOutput_0_maxOutputValue(_sampledFrame, _outputNBpixels);
        }else
        {
-               _spatiotemporalLPfilter_Irregular(&inputFrame[0], &_irregularLPfilteredFrame[0]);
+               _spatiotemporalLPfilter_Irregular(get_data(inputFrame), &_irregularLPfilteredFrame[0]);
                _spatiotemporalLPfilter_Irregular(&_irregularLPfilteredFrame[0], &_irregularLPfilteredFrame[0]);
                // applying image projection/resampling
                register unsigned int *transformTablePTR=&_transformTable[0];
index afe51ed..8956539 100644 (file)
@@ -181,7 +181,7 @@ void MagnoRetinaFilter::_amacrineCellsComputing(const double *OPL_ON, const doub
 const std::valarray<double> &MagnoRetinaFilter::runFilter(const std::valarray<double> &OPL_ON, const std::valarray<double> &OPL_OFF)
 {
        // Compute the high pass temporal filter
-       _amacrineCellsComputing(&OPL_ON[0], &OPL_OFF[0]);
+       _amacrineCellsComputing(get_data(OPL_ON), get_data(OPL_OFF));
 
        // apply low pass filtering on ON and OFF ways after temporal high pass filtering
        _spatiotemporalLPfilter(&_amacrinCellsTempOutput_ON[0], &_magnoXOutputON[0], 0);
index 519a3c4..4b730d0 100644 (file)
@@ -172,7 +172,7 @@ void ParvoRetinaFilter::setOPLandParvoFiltersParameters(const double beta1, cons
 // output return is (*_parvocellularOutputONminusOFF)
 const std::valarray<double> &ParvoRetinaFilter::runFilter(const std::valarray<double> &inputFrame, const bool useParvoOutput)
 {
-       _spatiotemporalLPfilter(&inputFrame[0], &_photoreceptorsOutput[0]);
+       _spatiotemporalLPfilter(get_data(inputFrame), &_photoreceptorsOutput[0]);
        _spatiotemporalLPfilter(&_photoreceptorsOutput[0], &_horizontalCellsOutput[0], 1);
        _OPL_OnOffWaysComputing();
 
index aab2c8f..1f0ef9b 100644 (file)
 #include "opencv2/imgproc/imgproc_c.h"
 #include "opencv2/core/internal.hpp"
 
+namespace cv
+{
+
+// special function to get pointer to constant valarray elements, since
+// simple &arr[0] does not compile on VS2005/VS2008.
+template<typename T> inline const T* get_data(const std::valarray<T>& arr)
+{ return &((std::valarray<T>&)arr)[0]; }
+
+}
+
 #endif
index c06f104..faa9b46 100644 (file)
@@ -372,7 +372,7 @@ void Retina::_init(const std::string parametersSaveFile, const cv::Size inputSiz
 void Retina::_convertValarrayGrayBuffer2cvMat(const std::valarray<double> &grayMatrixToConvert, const unsigned int nbRows, const unsigned int nbColumns, const bool colorMode, cv::Mat &outBuffer)
 {
        // fill output buffer with the valarray buffer
-       const double *valarrayPTR=&grayMatrixToConvert[0];
+       const double *valarrayPTR=get_data(grayMatrixToConvert);
        if (!colorMode)
        {
                outBuffer.create(cv::Size(nbColumns, nbRows), CV_8U);
index b317d7c..403dab4 100644 (file)
@@ -258,7 +258,7 @@ void RetinaColor::runColorDemultiplexing(const std::valarray<double> &multiplexe
        _demultiplexedTempBuffer=0;
        // -> demultiplex process
        register unsigned int *colorSamplingPRT=&_colorSampling[0];
-       register const double *multiplexedColorFramePTR=&multiplexedColorFrame[0];
+       register const double *multiplexedColorFramePTR=get_data(multiplexedColorFrame);
        for (unsigned int indexa=0; indexa<_filterOutput.getNBpixels() ; ++indexa)
                _demultiplexedTempBuffer[*(colorSamplingPRT++)]=*(multiplexedColorFramePTR++);
 
@@ -325,7 +325,7 @@ void RetinaColor::runColorDemultiplexing(const std::valarray<double> &multiplexe
 
        }else
        {
-               register const double *multiplexedColorFramePTR= &multiplexedColorFrame[0];
+               register const double *multiplexedColorFramePTR= get_data(multiplexedColorFrame);
                for (unsigned int indexc=0; indexc<_filterOutput.getNBpixels() ; ++indexc, ++chrominancePTR, ++colorLocalDensityPTR, ++luminance, ++multiplexedColorFramePTR)
                {
                        // normalize by photoreceptors density
@@ -723,9 +723,9 @@ const bool RetinaColor::applyLMS2LabTransform(std::valarray<double> &result)
 void RetinaColor::_applyImageColorSpaceConversion(const std::valarray<double> &inputFrameBuffer, std::valarray<double> &outputFrameBuffer, const double *transformTable)
 {
        // two step methods in order to allow inputFrame and outputFrame to be the same
-       unsigned int nbPixels=inputFrameBuffer.size()/3, dbpixels=2*inputFrameBuffer.size()/3;
+       unsigned int nbPixels=(unsigned int)(inputFrameBuffer.size()/3), dbpixels=(unsigned int)(2*inputFrameBuffer.size()/3);
 
-       const double *inputFrame=&inputFrameBuffer[0];
+       const double *inputFrame=get_data(inputFrameBuffer);
        double *outputFrame= &outputFrameBuffer[0];
 
        for (unsigned int dataIndex=0; dataIndex<nbPixels;++dataIndex, ++outputFrame, ++inputFrame)
index bb2408e..6729635 100644 (file)
@@ -240,7 +240,7 @@ void RetinaFilter::setGlobalParameters(const double OPLspatialResponse1, const d
        _setInitPeriodCount();
 }
 
-const bool RetinaFilter::checkInput(const std::valarray<double> &input, const bool colorMode)
+const bool RetinaFilter::checkInput(const std::valarray<double> &input, const bool)
 {
 
        BasicRetinaFilter *inputTarget=&_photoreceptorsPrefilter;
@@ -413,7 +413,7 @@ void RetinaFilter::runRGBToneMapping(const std::valarray<double> &RGBimageInput,
        RGBimageOutput=_colorEngine.getDemultiplexedColorFrame();
 }
 
-void RetinaFilter::runLMSToneMapping(const std::valarray<double> &LMSimageInput, std::valarray<double> &imageOuput, const bool useAdaptiveFiltering, const double PhotoreceptorsCompression, const double ganglionCellsCompression)
+void RetinaFilter::runLMSToneMapping(const std::valarray<double> &, std::valarray<double> &, const bool, const double, const double)
 {
        std::cerr<<"not working, sorry"<<std::endl;
 
@@ -474,8 +474,8 @@ void RetinaFilter::runLMSToneMapping(const std::valarray<double> &LMSimageInput,
 void RetinaFilter::_processRetinaParvoMagnoMapping()
 {
        register double *hybridParvoMagnoPTR= &_retinaParvoMagnoMappedFrame[0];
-       register const double *parvoOutputPTR= &(_ParvoRetinaFilter.getOutput()[0]);
-       register const double *magnoXOutputPTR= &(_MagnoRetinaFilter.getOutput()[0]);
+       register const double *parvoOutputPTR= get_data(_ParvoRetinaFilter.getOutput());
+       register const double *magnoXOutputPTR= get_data(_MagnoRetinaFilter.getOutput());
        register double *hybridParvoMagnoCoefTablePTR= &_retinaParvoMagnoMapCoefTable[0];
 
        for (unsigned int i=0 ; i<_photoreceptorsPrefilter.getNBpixels() ; ++i, hybridParvoMagnoCoefTablePTR+=2)
@@ -495,7 +495,7 @@ const bool RetinaFilter::getParvoFoveaResponse(std::valarray<double> &parvoFovea
        if (parvoFovealResponse.size() != _ParvoRetinaFilter.getNBpixels())
                return false;
 
-       register const double *parvoOutputPTR= &(_ParvoRetinaFilter.getOutput()[0]);
+       register const double *parvoOutputPTR= get_data(_ParvoRetinaFilter.getOutput());
        register double *fovealParvoResponsePTR= &parvoFovealResponse[0];
        register double *hybridParvoMagnoCoefTablePTR= &_retinaParvoMagnoMapCoefTable[0];
 
@@ -515,7 +515,7 @@ const bool RetinaFilter::getMagnoParaFoveaResponse(std::valarray<double> &magnoP
        if (magnoParafovealResponse.size() != _MagnoRetinaFilter.getNBpixels())
                return false;
 
-       register const double *magnoXOutputPTR= &(_MagnoRetinaFilter.getOutput()[0]);
+       register const double *magnoXOutputPTR= get_data(_MagnoRetinaFilter.getOutput());
        register double *parafovealMagnoResponsePTR=&magnoParafovealResponse[0];
        register double *hybridParvoMagnoCoefTablePTR=&_retinaParvoMagnoMapCoefTable[0]+1;
 
index 07a897c..14bcea9 100644 (file)
@@ -166,27 +166,27 @@ public:
        /**
        * @return the numbers of rows (height) of the images used by the object
        */
-       inline unsigned int getNBrows(){return _NBrows;};
+       inline unsigned int getNBrows(){return (unsigned int)_NBrows;};
 
        /**
        * @return the numbers of columns (width) of the images used by the object
        */
-       inline unsigned int getNBcolumns(){return _NBcolumns;};
+       inline unsigned int getNBcolumns(){return (unsigned int)_NBcolumns;};
 
        /**
        * @return the numbers of pixels (width*height) of the images used by the object
        */
-       inline unsigned int getNBpixels(){return _NBpixels;};
+       inline unsigned int getNBpixels(){return (unsigned int)_NBpixels;};
 
        /**
        * @return the numbers of pixels (width*height) of the images used by the object
        */
-       inline unsigned int getDoubleNBpixels(){return _doubleNBpixels;};
+       inline unsigned int getDoubleNBpixels(){return (unsigned int)_doubleNBpixels;};
 
        /**
        * @return the numbers of depths (3rd dimension: 1 for gray images, 3 for rgb images) of the images used by the object
        */
-       inline unsigned int getDepthSize(){return _NBdepths;};
+       inline unsigned int getDepthSize(){return (unsigned int)_NBdepths;};
 
        /**
        * resize the buffer and recompute table index etc.
@@ -260,7 +260,7 @@ public:
        * @param sensitivity: strenght of the sigmoide
        * @param maxOutputValue: the maximum output value
        */
-       inline void normalizeGrayOutputCentredSigmoide(const type meanValue=(type)0.0, const type sensitivity=(type)2.0, const type maxOutputValue=(type)255.0){normalizeGrayOutputCentredSigmoide(meanValue, sensitivity, 255.0, this->Buffer(), this->Buffer(), this->getNBpixels());};
+       inline void normalizeGrayOutputCentredSigmoide(const type meanValue=(type)0.0, const type sensitivity=(type)2.0, const type maxOutputValue=(type)255.0){normalizeGrayOutputCentredSigmoide(meanValue, sensitivity, 255.0, this->Buffer(), this->Buffer(), this->getNBpixels()), maxOutputValue;};
 
        /**
        * sigmoide image normalization function (saturates min and max values), in this function, the sigmoide is centered on low values (high saturation of the medium and high values