Skip to content
Snippets Groups Projects
Commit d2799d73 authored by Manuel Grizonnet's avatar Manuel Grizonnet
Browse files

WIP: use a shifted index to manage non zero index when box extended parameter is used

parent d399840f
No related branches found
No related tags found
No related merge requests found
...@@ -75,6 +75,7 @@ public: ...@@ -75,6 +75,7 @@ public:
typedef typename InputImageType::Pointer InputImagePointer; typedef typename InputImageType::Pointer InputImagePointer;
typedef typename InputImageType::RegionType InputImageRegionType; typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::PixelType InputImagePixelType; typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename InputImageType::IndexType InputIndexType;
typedef TInputImage OutputImageType; typedef TInputImage OutputImageType;
typedef typename OutputImageType::Pointer OutputImagePointer; typedef typename OutputImageType::Pointer OutputImagePointer;
typedef typename OutputImageType::RegionType OutputImageRegionType; typedef typename OutputImageType::RegionType OutputImageRegionType;
...@@ -156,19 +157,19 @@ public: ...@@ -156,19 +157,19 @@ public:
/** Set the only input of the writer */ /** Set the only input of the writer */
virtual void SetInput(const InputImageType *input); virtual void SetInput(const InputImageType *input);
/** Get writer only input */ /** Get writer only input */
const InputImageType* GetInput(); const InputImageType* GetInput();
/** Override Update() from ProcessObject because this filter /** Override Update() from ProcessObject because this filter
* has no output. */ * has no output. */
virtual void Update(); virtual void Update();
/** ImageFileWriter Methods */ /** ImageFileWriter Methods */
virtual void SetFileName(const char* extendedFileName); virtual void SetFileName(const char* extendedFileName);
virtual void SetFileName(std::string extendedFileName); virtual void SetFileName(std::string extendedFileName);
virtual const char* GetFileName () const; virtual const char* GetFileName () const;
/** Specify the region to write. If left NULL, then the whole image /** Specify the region to write. If left NULL, then the whole image
* is written. */ * is written. */
void SetIORegion(const itk::ImageIORegion& region); void SetIORegion(const itk::ImageIORegion& region);
...@@ -192,7 +193,7 @@ public: ...@@ -192,7 +193,7 @@ public:
itkSetObjectMacro(ImageIO, otb::ImageIOBase); itkSetObjectMacro(ImageIO, otb::ImageIOBase);
itkGetObjectMacro(ImageIO, otb::ImageIOBase); itkGetObjectMacro(ImageIO, otb::ImageIOBase);
itkGetConstObjectMacro(ImageIO, otb::ImageIOBase); itkGetConstObjectMacro(ImageIO, otb::ImageIOBase);
protected: protected:
ImageFileWriter(); ImageFileWriter();
virtual ~ImageFileWriter(); virtual ~ImageFileWriter();
...@@ -244,7 +245,7 @@ private: ...@@ -244,7 +245,7 @@ private:
bool m_UseInputMetaDataDictionary; // whether to use the bool m_UseInputMetaDataDictionary; // whether to use the
// MetaDataDictionary from the // MetaDataDictionary from the
// input or not. // input or not.
bool m_WriteGeomFile; // Write a geom file to store the bool m_WriteGeomFile; // Write a geom file to store the
// kwl // kwl
...@@ -254,6 +255,7 @@ private: ...@@ -254,6 +255,7 @@ private:
bool m_IsObserving; bool m_IsObserving;
unsigned long m_ObserverID; unsigned long m_ObserverID;
InputIndexType m_ShiftOutputIndex;
}; };
} // end namespace otb } // end namespace otb
......
...@@ -68,6 +68,9 @@ ImageFileWriter<TInputImage> ...@@ -68,6 +68,9 @@ ImageFileWriter<TInputImage>
m_IsObserving(true), m_IsObserving(true),
m_ObserverID(0) m_ObserverID(0)
{ {
//Init output index shift
m_ShiftOutputIndex.Fill(0);
// By default, we use tiled streaming, with automatic tile size // By default, we use tiled streaming, with automatic tile size
// We don't set any parameter, so the memory size is retrieved from the OTB configuration options // We don't set any parameter, so the memory size is retrieved from the OTB configuration options
this->SetAutomaticAdaptativeStreaming(); this->SetAutomaticAdaptativeStreaming();
...@@ -494,7 +497,9 @@ ImageFileWriter<TInputImage> ...@@ -494,7 +497,9 @@ ImageFileWriter<TInputImage>
size[1] = atoi(it->c_str()); // size along Y size[1] = atoi(it->c_str()); // size along Y
inputRegion.SetSize(size); inputRegion.SetSize(size);
inputRegion.SetIndex(start);
m_ShiftOutputIndex = start;
inputRegion.SetIndex(m_ShiftOutputIndex);
otbMsgDevMacro(<< "inputRegion " << inputRegion); otbMsgDevMacro(<< "inputRegion " << inputRegion);
...@@ -623,7 +628,8 @@ ImageFileWriter<TInputImage> ...@@ -623,7 +628,8 @@ ImageFileWriter<TInputImage>
{ {
ioRegion.SetSize(i, streamRegion.GetSize(i)); ioRegion.SetSize(i, streamRegion.GetSize(i));
ioRegion.SetIndex(i, streamRegion.GetIndex(i)); ioRegion.SetIndex(i, streamRegion.GetIndex(i));
//ioRegion.SetIndex(i, streamRegion.GetIndex(i) - inputRegion.GetIndex(i)); //Set the ioRegion index using the shifted index ( (0,0 without box parameter))
ioRegion.SetIndex(i, streamRegion.GetIndex(i) - m_ShiftOutputIndex[i]);
} }
otbMsgDevMacro(<< "ioregion " << ioRegion ) otbMsgDevMacro(<< "ioregion " << ioRegion )
this->SetIORegion(ioRegion); this->SetIORegion(ioRegion);
...@@ -711,7 +717,8 @@ ImageFileWriter<TInputImage> ...@@ -711,7 +717,8 @@ ImageFileWriter<TInputImage>
typename InputImageRegionType::IndexType tmpIndex; typename InputImageRegionType::IndexType tmpIndex;
tmpIndex.Fill(0); tmpIndex.Fill(0);
itk::ImageIORegionAdaptor<TInputImage::ImageDimension>:: itk::ImageIORegionAdaptor<TInputImage::ImageDimension>::
Convert(m_ImageIO->GetIORegion(), ioRegion, tmpIndex); //Convert(m_ImageIO->GetIORegion(), ioRegion, tmpIndex);
Convert(m_ImageIO->GetIORegion(), ioRegion, m_ShiftOutputIndex);
InputImageRegionType bufferedRegion = input->GetBufferedRegion(); InputImageRegionType bufferedRegion = input->GetBufferedRegion();
// before this test, bad stuff would happend when they don't match // before this test, bad stuff would happend when they don't match
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment