21 #ifndef otbStreamingManager_hxx
22 #define otbStreamingManager_hxx
26 #include "itkExtractImageFilter.h"
31 template <
class TImage>
36 template <
class TImage>
41 template <
class TImage>
47 template <
class TImage>
52 if (availableRAMInBytes == 0)
54 if (m_DefaultRAM != 0)
56 availableRAMInBytes = 1024 * 1024 * m_DefaultRAM;
64 return availableRAMInBytes;
67 template <
class TImage>
71 MemoryPrintType availableRAMInBytes = GetActualAvailableRAMInBytes(availableRAM);
78 double regionTrickFactor = 1;
85 typedef itk::ExtractImageFilter<ImageType, ImageType> ExtractFilterType;
86 typename ExtractFilterType::Pointer extractFilter = ExtractFilterType::New();
87 extractFilter->SetInput(inputImage);
94 index[0] = region.GetIndex()[0] + region.GetSize()[0] / 2 - 50;
95 index[1] = region.GetIndex()[1] + region.GetSize()[1] / 2 - 50;
98 smallRegion.SetSize(smallSize);
99 smallRegion.SetIndex(index);
102 smallRegion.Crop(region);
104 extractFilter->SetExtractionRegion(smallRegion);
106 bool smallRegionSuccess = smallRegion.Crop(region);
108 if (smallRegionSuccess)
111 memoryPrintCalculator->SetDataToWrite(extractFilter->GetOutput());
113 regionTrickFactor =
static_cast<double>(region.GetNumberOfPixels()) /
static_cast<double>(smallRegion.GetNumberOfPixels());
115 memoryPrintCalculator->SetBiasCorrectionFactor(regionTrickFactor * bias);
121 memoryPrintCalculator->SetDataToWrite(input);
122 memoryPrintCalculator->SetBiasCorrectionFactor(bias);
125 memoryPrintCalculator->Compute();
127 pipelineMemoryPrint = memoryPrintCalculator->GetMemoryPrint();
129 if (smallRegionSuccess)
132 MemoryPrintType extractContrib = memoryPrintCalculator->EvaluateDataObjectPrint(extractFilter->GetOutput());
134 pipelineMemoryPrint -= extractContrib;
140 memoryPrintCalculator->SetDataToWrite(input);
141 memoryPrintCalculator->SetBiasCorrectionFactor(1.0);
143 memoryPrintCalculator->Compute();
145 pipelineMemoryPrint = memoryPrintCalculator->GetMemoryPrint();
152 <<
" MB), optimal image partitioning: " << optimalNumberOfDivisions <<
" blocks");
154 return optimalNumberOfDivisions;
157 template <
class TImage>
160 return m_ComputedNumberOfSplits;
163 template <
class TImage>
167 m_Splitter->GetSplit(i, m_ComputedNumberOfSplits, region);
static RAMValueType GetMaxRAMHint()
static const double ByteToMegabyte
static unsigned long EstimateOptimalNumberOfStreamDivisions(MemoryPrintType memoryPrint, MemoryPrintType availableMemory)
itk::SmartPointer< Self > Pointer
RegionType::IndexType IndexType
virtual RegionType GetSplit(unsigned int i)
~StreamingManager() override
virtual unsigned int EstimateOptimalNumberOfDivisions(itk::DataObject *input, const RegionType ®ion, MemoryPrintType availableRAMInMB, double bias=1.0)
otb::PipelineMemoryPrintCalculator::MemoryPrintType MemoryPrintType
MemoryPrintType GetActualAvailableRAMInBytes(MemoryPrintType availableRAMInMB)
const AbstractSplitterType * GetSplitter() const
RegionType::SizeType SizeType
virtual unsigned int GetNumberOfSplits()
itk::ImageRegionSplitterBase AbstractSplitterType
ImageType::RegionType RegionType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
#define otbLogMacro(level, msg)