From b187c9a635b3fae949efe8176e9eec44c3bf04ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Traizet?= <traizetc@cesbio.cnes.fr> Date: Wed, 17 May 2017 13:57:26 +0200 Subject: [PATCH] confidence map removed --- app/cbDimensionalityReduction.cxx | 18 +--- include/AutoencoderModel.h | 9 +- include/AutoencoderModel.txx | 6 +- include/DimensionalityReductionModel.h | 39 ++------ include/DimensionalityReductionModel.txx | 95 ++++++------------- .../DimensionalityReductionModelFactory.txx | 9 +- .../ImageDimensionalityReductionFilter.txx | 35 +------ include/PCAModel.h | 9 +- include/PCAModel.txx | 6 +- include/SOMModel.h | 7 +- include/SOMModel.txx | 6 +- 11 files changed, 66 insertions(+), 173 deletions(-) diff --git a/app/cbDimensionalityReduction.cxx b/app/cbDimensionalityReduction.cxx index 7b1063147b..6d5366e9eb 100644 --- a/app/cbDimensionalityReduction.cxx +++ b/app/cbDimensionalityReduction.cxx @@ -145,8 +145,6 @@ private: AddParameter(ParameterType_InputImage, "in", "Input Image"); SetParameterDescription( "in", "The input image to predict."); - // TODO : use CSV input/output ? - AddParameter(ParameterType_InputImage, "mask", "Input Mask"); SetParameterDescription( "mask", "The mask allow restricting " "classification of the input image to the area where mask pixel values " @@ -200,7 +198,6 @@ private: } m_Model->Load(GetParameterString("model")); - m_Model->SetRegressionMode(true); otbAppLogINFO("Model loaded"); // Classify @@ -218,25 +215,14 @@ private: MeasurementType meanMeasurementVector; MeasurementType stddevMeasurementVector; m_Rescaler = RescalerType::New(); + // Load input image statistics statisticsReader->SetFileName(GetParameterString("imstat")); meanMeasurementVector = statisticsReader->GetStatisticVectorByName("mean"); stddevMeasurementVector = statisticsReader->GetStatisticVectorByName("stddev"); otbAppLogINFO( "mean used: " << meanMeasurementVector ); otbAppLogINFO( "standard deviation used: " << stddevMeasurementVector ); - /*if (meanMeasurementVector.Size() == nbFeatures + 1) - { - double outMean = meanMeasurementVector[nbFeatures]; - double outStdDev = stddevMeasurementVector[nbFeatures]; - meanMeasurementVector.SetSize(nbFeatures,false); - stddevMeasurementVector.SetSize(nbFeatures,false); - m_OutRescaler = OutputRescalerType::New(); - m_OutRescaler->SetInput(m_ClassificationFilter->GetOutput()); - m_OutRescaler->GetFunctor().SetA(outStdDev); - m_OutRescaler->GetFunctor().SetB(outMean); - outputImage = m_OutRescaler->GetOutput(); - } - else*/ if (meanMeasurementVector.Size() != nbFeatures) + if (meanMeasurementVector.Size() != nbFeatures) { otbAppLogFATAL("Wrong number of components in statistics file : "<<meanMeasurementVector.Size()); } diff --git a/include/AutoencoderModel.h b/include/AutoencoderModel.h index 7ebb95de6f..eb65fdb1df 100644 --- a/include/AutoencoderModel.h +++ b/include/AutoencoderModel.h @@ -23,10 +23,7 @@ public: typedef typename Superclass::TargetValueType TargetValueType; typedef typename Superclass::TargetSampleType TargetSampleType; typedef typename Superclass::TargetListSampleType TargetListSampleType; - typedef typename Superclass::ConfidenceValueType ConfidenceValueType; - typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; - typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - + itkNewMacro(Self); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); @@ -54,8 +51,8 @@ protected: AutoencoderModel(); ~AutoencoderModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; - virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; + virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *) const ITK_OVERRIDE; private: diff --git a/include/AutoencoderModel.txx b/include/AutoencoderModel.txx index b0e206532f..7f2b451647 100644 --- a/include/AutoencoderModel.txx +++ b/include/AutoencoderModel.txx @@ -19,7 +19,7 @@ namespace otb template <class TInputValue, class AutoencoderType> AutoencoderModel<TInputValue,AutoencoderType>::AutoencoderModel() { - this->m_IsRegressionSupported = true; + this->m_IsDoPredictBatchMultiThreaded = true; } @@ -117,7 +117,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil template <class TInputValue, class AutoencoderType> typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType -AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value) const { shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) @@ -143,7 +143,7 @@ AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & template <class TInputValue, class AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType> -::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const { std::cout << "BATCH" << std::endl; std::vector<shark::RealVector> features; diff --git a/include/DimensionalityReductionModel.h b/include/DimensionalityReductionModel.h index ba9888b1fb..4f12b1e2ef 100644 --- a/include/DimensionalityReductionModel.h +++ b/include/DimensionalityReductionModel.h @@ -62,7 +62,7 @@ namespace otb * * \ingroup OTBSupervised */ -template <class TInputValue, class TTargetValue, class TConfidenceValue = double > +template <class TInputValue, class TTargetValue> class ITK_EXPORT DimensionalityReductionModel : public itk::Object { @@ -89,11 +89,6 @@ public: typedef itk::Statistics::ListSample<TargetSampleType> TargetListSampleType; //@} - /**\name Confidence value typedef */ - typedef TConfidenceValue ConfidenceValueType; - typedef itk::FixedArray<ConfidenceValueType,1> ConfidenceSampleType; - typedef itk::Statistics::ListSample<ConfidenceSampleType> ConfidenceListSampleType; - /**\name Standard macros */ //@{ /** Run-time type information (and related methods). */ @@ -109,7 +104,7 @@ public: * quality value, or NULL * \return The predicted label */ - TargetSampleType Predict(const InputSampleType& input, ConfidenceValueType *quality = ITK_NULLPTR) const; + TargetSampleType Predict(const InputSampleType& input) const; @@ -121,7 +116,7 @@ public: * Note that this method will be multi-threaded if OTB is built * with OpenMP. */ - typename TargetListSampleType::Pointer PredictBatch(const InputListSampleType * input, ConfidenceListSampleType * quality = ITK_NULLPTR) const; + typename TargetListSampleType::Pointer PredictBatch(const InputListSampleType * input) const; /** THIS METHOD IS DEPRECATED AND SHOULD NOT BE USED. */ void PredictAll(); @@ -147,9 +142,6 @@ public: virtual bool CanWriteFile(const std::string &) = 0; //@} - /** Query capacity to produce a confidence index */ - bool HasConfidenceIndex() const {return m_ConfidenceIndex;} - /**\name Input list of samples accessors */ //@{ itkSetObjectMacro(InputListSample,InputListSampleType); @@ -165,13 +157,7 @@ public: itkGetObjectMacro(TargetListSample,TargetListSampleType); //@} - itkGetObjectMacro(ConfidenceListSample,ConfidenceListSampleType); - - /**\name Use model in regression mode */ - //@{ - itkGetMacro(RegressionMode,bool); - void SetRegressionMode(bool flag); - //@} + protected: /** Constructor */ @@ -189,19 +175,6 @@ protected: /** Target list sample */ typename TargetListSampleType::Pointer m_TargetListSample; - typename ConfidenceListSampleType::Pointer m_ConfidenceListSample; - - /** flag to choose between classification and regression modes */ - bool m_RegressionMode; - - /** flag that indicates if the model supports regression, child - * classes should modify it in their constructor if they support - * regression mode */ - bool m_IsRegressionSupported; - - /** flag that tells if the model support confidence index output */ - bool m_ConfidenceIndex; - /** Is DoPredictBatch multi-threaded ? */ bool m_IsDoPredictBatchMultiThreaded; @@ -225,7 +198,7 @@ private: * Also set m_IsDoPredictBatchMultiThreaded to true if internal * implementation allows for parallel batch prediction. */ - virtual void DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * target, ConfidenceListSampleType * quality = ITK_NULLPTR) const; + virtual void DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * target) const; /** Actual implementation of single sample prediction * \param input sample to predict @@ -233,7 +206,7 @@ private: * or NULL * \return The predicted label */ - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality= ITK_NULLPTR) const = 0; + virtual TargetSampleType DoPredict(const InputSampleType& input) const = 0; DimensionalityReductionModel(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented diff --git a/include/DimensionalityReductionModel.txx b/include/DimensionalityReductionModel.txx index 68db8019a3..ba20ee8e28 100644 --- a/include/DimensionalityReductionModel.txx +++ b/include/DimensionalityReductionModel.txx @@ -29,40 +29,21 @@ namespace otb { -template <class TInputValue, class TOutputValue, class TConfidenceValue> -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::DimensionalityReductionModel() : - m_RegressionMode(false), - m_IsRegressionSupported(false), - m_ConfidenceIndex(false), - m_IsDoPredictBatchMultiThreaded(false) -{} +template <class TInputValue, class TOutputValue> +DimensionalityReductionModel<TInputValue,TOutputValue> +::DimensionalityReductionModel() +{ this->m_IsDoPredictBatchMultiThreaded=false;} -template <class TInputValue, class TOutputValue, class TConfidenceValue> -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +template <class TInputValue, class TOutputValue> +DimensionalityReductionModel<TInputValue,TOutputValue> ::~DimensionalityReductionModel() {} -template <class TInputValue, class TOutputValue, class TConfidenceValue> -void -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::SetRegressionMode(bool flag) -{ - if (flag && !m_IsRegressionSupported) - { - itkGenericExceptionMacro(<< "Regression mode not implemented."); - } - if (m_RegressionMode != flag) - { - m_RegressionMode = flag; - this->Modified(); - } -} -template <class TInputValue, class TOutputValue, class TConfidenceValue> +template <class TInputValue, class TOutputValue> void -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +DimensionalityReductionModel<TInputValue,TOutputValue> ::PredictAll() { itkWarningMacro("DimensionalityReductionModel::PredictAll() has been DEPRECATED. Use DimensionalityReductionModel::PredictBatch() instead."); @@ -75,36 +56,31 @@ DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> targets->Graft(tmpTargets); } -template <class TInputValue, class TOutputValue, class TConfidenceValue> -typename DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +template <class TInputValue, class TOutputValue> +typename DimensionalityReductionModel<TInputValue,TOutputValue> ::TargetSampleType -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::Predict(const InputSampleType& input, ConfidenceValueType *quality) const +DimensionalityReductionModel<TInputValue,TOutputValue> +::Predict(const InputSampleType& input) const { // Call protected specialization entry point - return this->DoPredict(input,quality); + return this->DoPredict(input); } -template <class TInputValue, class TOutputValue, class TConfidenceValue> -typename DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +template <class TInputValue, class TOutputValue> +typename DimensionalityReductionModel<TInputValue,TOutputValue> ::TargetListSampleType::Pointer -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::PredictBatch(const InputListSampleType * input, ConfidenceListSampleType * quality) const +DimensionalityReductionModel<TInputValue,TOutputValue> +::PredictBatch(const InputListSampleType * input) const { typename TargetListSampleType::Pointer targets = TargetListSampleType::New(); targets->Resize(input->Size()); - if(quality!=ITK_NULLPTR) - { - quality->Clear(); - quality->Resize(input->Size()); - } if(m_IsDoPredictBatchMultiThreaded) { // Simply calls DoPredictBatch - this->DoPredictBatch(input,0,input->Size(),targets,quality); + this->DoPredictBatch(input,0,input->Size(),targets); return targets; } else @@ -131,11 +107,11 @@ DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> batch_size+=input->Size()%nb_batches; } - this->DoPredictBatch(input,batch_start,batch_size,targets,quality); + this->DoPredictBatch(input,batch_start,batch_size,targets); } } #else - this->DoPredictBatch(input,0,input->Size(),targets,quality); + this->DoPredictBatch(input,0,input->Size(),targets); #endif return targets; } @@ -143,10 +119,10 @@ DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -template <class TInputValue, class TOutputValue, class TConfidenceValue> +template <class TInputValue, class TOutputValue> void -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> -::DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +DimensionalityReductionModel<TInputValue,TOutputValue> +::DoPredictBatch(const InputListSampleType * input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const { assert(input != ITK_NULLPTR); assert(targets != ITK_NULLPTR); @@ -159,29 +135,18 @@ DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> itkExceptionMacro(<<"requested range ["<<startIndex<<", "<<startIndex+size<<"[ partially outside input sample list range.[0,"<<input->Size()<<"["); } - if(quality != ITK_NULLPTR) - { - for(unsigned int id = startIndex;id<startIndex+size;++id) - { - ConfidenceValueType confidence = 0; - const TargetSampleType target = this->DoPredict(input->GetMeasurementVector(id),&confidence); - quality->SetMeasurementVector(id,confidence); - targets->SetMeasurementVector(id,target); - } - } - else + + for(unsigned int id = startIndex;id<startIndex+size;++id) { - for(unsigned int id = startIndex;id<startIndex+size;++id) - { - const TargetSampleType target = this->DoPredict(input->GetMeasurementVector(id)); - targets->SetMeasurementVector(id,target); - } + const TargetSampleType target = this->DoPredict(input->GetMeasurementVector(id)); + targets->SetMeasurementVector(id,target); } + } -template <class TInputValue, class TOutputValue, class TConfidenceValue> +template <class TInputValue, class TOutputValue> void -DimensionalityReductionModel<TInputValue,TOutputValue,TConfidenceValue> +DimensionalityReductionModel<TInputValue,TOutputValue> ::PrintSelf(std::ostream& os, itk::Indent indent) const { // Call superclass implementation diff --git a/include/DimensionalityReductionModelFactory.txx b/include/DimensionalityReductionModelFactory.txx index 585af208aa..5fba93346e 100644 --- a/include/DimensionalityReductionModelFactory.txx +++ b/include/DimensionalityReductionModelFactory.txx @@ -42,6 +42,9 @@ template <class TInputValue, class TTargetValue> using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; +template <class TInputValue, class TTargetValue> +using SOM3DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ; + template <class TInputValue, class TOutputValue> typename DimensionalityReductionModel<TInputValue,TOutputValue>::Pointer DimensionalityReductionModelFactory<TInputValue,TOutputValue> @@ -99,7 +102,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> - RegisterFactory(SOMModelFactory<TInputValue,TOutputValue>::New()); + RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New()); #ifdef OTB_USE_SHARK RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); @@ -135,8 +138,8 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> { // SOM - SOMModelFactory<TInputValue,TOutputValue> *somFactory = - dynamic_cast<SOMModelFactory<TInputValue,TOutputValue> *>(*itFac); + SOM3DModelFactory<TInputValue,TOutputValue> *somFactory = + dynamic_cast<SOM3DModelFactory<TInputValue,TOutputValue> *>(*itFac); if (somFactory) { itk::ObjectFactoryBase::UnRegisterFactory(somFactory); diff --git a/include/ImageDimensionalityReductionFilter.txx b/include/ImageDimensionalityReductionFilter.txx index 9f5b34cab2..9060270636 100644 --- a/include/ImageDimensionalityReductionFilter.txx +++ b/include/ImageDimensionalityReductionFilter.txx @@ -144,8 +144,6 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> ::BatchThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) { - bool computeConfidenceMap(m_UseConfidenceMap && m_Model->HasConfidenceIndex() - && !m_Model->GetRegressionMode()); // Get the input pointers InputImageConstPointerType inputPtr = this->GetInput(); MaskImageConstPointerType inputMaskPtr = this->GetInputMask(); @@ -172,8 +170,7 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> typedef typename ModelType::TargetListSampleType TargetListSampleType; // typedef typename ModelType::ConfidenceValueType ConfidenceValueType; // typedef typename ModelType::ConfidenceSampleType ConfidenceSampleType; - typedef typename ModelType::ConfidenceListSampleType ConfidenceListSampleType; - + typename InputListSampleType::Pointer samples = InputListSampleType::New(); unsigned int num_features = inputPtr->GetNumberOfComponentsPerPixel(); samples->SetMeasurementVectorSize(num_features); @@ -193,45 +190,23 @@ ImageDimensionalityReductionFilter<TInputImage, TOutputImage, TMaskImage> } //Make the batch prediction typename TargetListSampleType::Pointer labels; - typename ConfidenceListSampleType::Pointer confidences; - if(computeConfidenceMap) - confidences = ConfidenceListSampleType::New(); - + // This call is threadsafe //labels = m_Model->PredictBatch(samples,confidences); labels = m_Model->PredictBatch(samples); // Set the output values - ConfidenceMapIteratorType confidenceIt; - if (computeConfidenceMap) - { - confidenceIt = ConfidenceMapIteratorType(confidencePtr,outputRegionForThread); - confidenceIt.GoToBegin(); - } + typename TargetListSampleType::ConstIterator labIt = labels->Begin(); for (outIt.GoToBegin(); !outIt.IsAtEnd(); ++outIt) { - double confidenceIndex = 0.0; - + itk::VariableLengthVector<TargetValueType> labelValue; - + labelValue = labIt.GetMeasurementVector(); - - if(computeConfidenceMap) - { - confidenceIndex = confidences->GetMeasurementVector(labIt.GetInstanceIdentifier())[0]; - } - ++labIt; - outIt.Set(labelValue); - if(computeConfidenceMap) - { - confidenceIt.Set(confidenceIndex); - ++confidenceIt; - } - progress.CompletedPixel(); } } diff --git a/include/PCAModel.h b/include/PCAModel.h index 4ea1370a9f..45693dfc8a 100644 --- a/include/PCAModel.h +++ b/include/PCAModel.h @@ -23,10 +23,7 @@ public: typedef typename Superclass::TargetValueType TargetValueType; typedef typename Superclass::TargetSampleType TargetSampleType; typedef typename Superclass::TargetListSampleType TargetListSampleType; - typedef typename Superclass::ConfidenceValueType ConfidenceValueType; - typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; - typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; - + itkNewMacro(Self); itkTypeMacro(PCAModel, DimensionalityReductionModel); @@ -47,8 +44,8 @@ protected: PCAModel(); ~PCAModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; - virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * = ITK_NULLPTR) const ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; + virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *) const ITK_OVERRIDE; private: shark::LinearModel<> m_encoder; diff --git a/include/PCAModel.txx b/include/PCAModel.txx index 92fdc3ee4c..8f48040388 100644 --- a/include/PCAModel.txx +++ b/include/PCAModel.txx @@ -19,7 +19,7 @@ namespace otb template <class TInputValue> PCAModel<TInputValue>::PCAModel() { - this->m_IsRegressionSupported = true; + this->m_IsDoPredictBatchMultiThreaded = true; } @@ -100,7 +100,7 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string template <class TInputValue> typename PCAModel<TInputValue>::TargetSampleType -PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +PCAModel<TInputValue>::DoPredict(const InputSampleType & value) const { shark::RealVector samples(value.Size()); for(size_t i = 0; i < value.Size();i++) @@ -126,7 +126,7 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueT template <class TInputValue> void PCAModel<TInputValue> -::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const +::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const { std::vector<shark::RealVector> features; diff --git a/include/SOMModel.h b/include/SOMModel.h index b7adddd663..bec029b9a4 100644 --- a/include/SOMModel.h +++ b/include/SOMModel.h @@ -15,7 +15,7 @@ namespace otb { -template <class TInputValue> +template <class TInputValue, unsigned int MapDimension>> class ITK_EXPORT SOMModel: public DimensionalityReductionModel<TInputValue,TInputValue> { @@ -33,9 +33,6 @@ public: typedef typename Superclass::TargetValueType TargetValueType; typedef typename Superclass::TargetSampleType TargetSampleType; typedef typename Superclass::TargetListSampleType TargetListSampleType; - typedef typename Superclass::ConfidenceValueType ConfidenceValueType; - typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType; - typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType; typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> MapType; typedef typename MapType::SizeType SizeType; @@ -85,7 +82,7 @@ protected: SOMModel(); ~SOMModel() ITK_OVERRIDE; - virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType *quality=ITK_NULLPTR) const ITK_OVERRIDE; + virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; private: typename MapType::Pointer m_SOMMap; diff --git a/include/SOMModel.txx b/include/SOMModel.txx index 5c6be685ba..872cd34c02 100644 --- a/include/SOMModel.txx +++ b/include/SOMModel.txx @@ -14,7 +14,6 @@ namespace otb template <class TInputValue> SOMModel<TInputValue>::SOMModel() { - this->m_IsRegressionSupported = true; } @@ -42,6 +41,7 @@ void SOMModel<TInputValue>::Train() estimator->Update(); m_SOMMap = estimator->GetOutput(); + std::cout << "dr of the first sample : " << m_SOMMap->GetWinner(m_ListSample->GetMeasurementVector(0)) << std::endl; } @@ -95,14 +95,14 @@ void SOMModel<TInputValue>::Load(const std::string & filename, const std::string template <class TInputValue> typename SOMModel<TInputValue>::TargetSampleType -SOMModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType *quality) const +SOMModel<TInputValue>::DoPredict(const InputSampleType & value) const { unsigned int dimension =MapType::ImageDimension; TargetSampleType target; target.SetSize(dimension); auto winner =m_SOMMap->GetWinner(value); - + // std::cout << winner << std::endl; for (int i=0; i< dimension ;i++) { target[i] = winner.GetElement(i); -- GitLab