diff --git a/app/otbPatchesExtraction.cxx b/app/otbPatchesExtraction.cxx index 2f9cee23781984f9f9749b7cd3c360274c5230fd..64aa24e8b2f6a5998cb814ac5c91440dba70604a 100644 --- a/app/otbPatchesExtraction.cxx +++ b/app/otbPatchesExtraction.cxx @@ -197,8 +197,14 @@ public: SamplerType::Pointer sampler = SamplerType::New(); sampler->SetInputVectorData(GetParameterVectorData("vec")); sampler->SetField(GetParameterAsString("field")); - sampler->SetRejectPatchesWithNodata(GetParameterInt("usenodata")==1); - sampler->SetNodataValue(GetParameterFloat("nodataval")); + if (GetParameterInt("usenodata")==1) + { + otbAppLogINFO("Rejecting samples that have at least one no-data value"); + sampler->SetRejectPatchesWithNodata(true); + float ndval = GetParameterFloat("nodataval"); + otbAppLogINFO("No-data value: " << ndval); + sampler->SetNodataValue(ndval); + } for (auto& bundle: m_Bundles) { sampler->PushBackInputWithPatchSize(bundle.m_ImageSource.Get(), bundle.m_PatchSize); diff --git a/include/otbTensorflowSampler.hxx b/include/otbTensorflowSampler.hxx index 8c5d98970043ada5b5e617c5da19d6be62e93cea..4b2d8c77a071549203bb9ae105437d939b12de6e 100644 --- a/include/otbTensorflowSampler.hxx +++ b/include/otbTensorflowSampler.hxx @@ -20,6 +20,10 @@ template <class TInputImage, class TVectorData> TensorflowSampler<TInputImage, TVectorData> ::TensorflowSampler() { + m_NumberOfAcceptedSamples = 0; + m_NumberOfRejectedSamples = 0; + m_RejectPatchesWithNodata = false; + m_NodataValue = 0; } template <class TInputImage, class TVectorData> @@ -199,7 +203,7 @@ TensorflowSampler<TInputImage, TVectorData> hasBeenSampled = false; break; } - if (hasBeenSampled) + if (!hasBeenSampled) break; }