Commit e368cd0b authored by Julien Michel's avatar Julien Michel

BUG: Fixing bug #1467. No Update() should happen on filters whatsoever, unless...

BUG: Fixing bug #1467. No Update() should happen on filters whatsoever, unless you know for sure that the Udpate() call will not load whole image in memory. No local pointers to filters are allowed (because the streaming pipeline disappears at the end of the method)
parent e3aa3f9b
...@@ -222,6 +222,10 @@ private: ...@@ -222,6 +222,10 @@ private:
template<class TImageType> template<class TImageType>
void GenericDoExecute() void GenericDoExecute()
{ {
// Clear previously registered filters
m_Filters.clear();
std::string rescaleType = this->GetParameterString("type"); std::string rescaleType = this->GetParameterString("type");
if( (rescaleType != "none") && (rescaleType != "linear") && (rescaleType != "log2") ) if( (rescaleType != "none") && (rescaleType != "linear") && (rescaleType != "log2") )
...@@ -383,7 +387,7 @@ private: ...@@ -383,7 +387,7 @@ private:
rescaler->SetGamma(GetParameterFloat("type.linear.gamma")); rescaler->SetGamma(GetParameterFloat("type.linear.gamma"));
} }
m_TmpFilter = rescaler; m_Filters.push_back(rescaler.GetPointer());
SetParameterOutputImage<TImageType>("out", rescaler->GetOutput()); SetParameterOutputImage<TImageType>("out", rescaler->GetOutput());
} }
...@@ -440,19 +444,19 @@ private: ...@@ -440,19 +444,19 @@ private:
{ {
typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType, typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType,
typename TImageType::InternalPixelType> ExtractROIFilterType; typename TImageType::InternalPixelType> ExtractROIFilterType;
typedef ObjectList<ExtractROIFilterType> ExtractROIFilterListType;
typedef otb::ImageList<otb::Image<typename TImageType::InternalPixelType> > ImageListType; typedef otb::ImageList<otb::Image<typename TImageType::InternalPixelType> > ImageListType;
typedef ImageListToVectorImageFilter<ImageListType, typedef ImageListToVectorImageFilter<ImageListType,
TImageType > ListConcatenerFilterType; TImageType > ListConcatenerFilterType;
typename ImageListType::Pointer imageList; typename ImageListType::Pointer imageList;
typename ListConcatenerFilterType::Pointer concatener; typename ListConcatenerFilterType::Pointer concatener;
typename ExtractROIFilterListType::Pointer extractorList;
imageList = ImageListType::New(); imageList = ImageListType::New();
concatener = ListConcatenerFilterType::New(); concatener = ListConcatenerFilterType::New();
extractorList = ExtractROIFilterListType::New();
//m_Filters.push_back(imageList.GetPointer());
m_Filters.push_back(concatener.GetPointer());
const bool monoChannel = IsParameterEnabled("channels.grayscale"); const bool monoChannel = IsParameterEnabled("channels.grayscale");
// get band order // get band order
...@@ -461,16 +465,15 @@ private: ...@@ -461,16 +465,15 @@ private:
for (auto && channel : channels) for (auto && channel : channels)
{ {
typename ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New(); typename ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New();
m_Filters.push_back(extractROIFilter.GetPointer());
extractROIFilter->SetInput(GetParameterImage("in")); extractROIFilter->SetInput(GetParameterImage("in"));
if (!monoChannel) extractROIFilter->SetChannel(channel); if (!monoChannel) extractROIFilter->SetChannel(channel);
extractROIFilter->UpdateOutputInformation(); extractROIFilter->UpdateOutputInformation();
extractorList->PushBack(extractROIFilter);
imageList->PushBack(extractROIFilter->GetOutput()); imageList->PushBack(extractROIFilter->GetOutput());
} }
concatener->SetInput(imageList); concatener->SetInput(imageList);
concatener->UpdateOutputInformation(); concatener->UpdateOutputInformation();
concatener->Update();
return concatener->GetOutput(); return concatener->GetOutput();
} }
...@@ -507,8 +510,8 @@ private: ...@@ -507,8 +510,8 @@ private:
} }
} }
itk::ProcessObject::Pointer m_TmpFilter;
TransferLogType::Pointer m_TransferLog; TransferLogType::Pointer m_TransferLog;
std::vector<itk::LightObject::Pointer> m_Filters;
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment