Commit 23c3eac9 authored by Julien Malik's avatar Julien Malik

BACKOUT: revert changes in ImageRegionSquareTileSplitter, buggy and too much impact

parent 3f70633e
......@@ -124,7 +124,7 @@ public:
itkGetMacro(TileDimension, unsigned int);
protected:
ImageRegionSquareTileSplitter() : m_SplitsPerDimension(0U), m_TileDimension(0), m_TileSizeAlignment(0), m_TileHint(2048) {}
ImageRegionSquareTileSplitter() : m_SplitsPerDimension(0U), m_TileDimension(0), m_TileSizeAlignment(16) {}
virtual ~ImageRegionSquareTileSplitter() {}
void PrintSelf(std::ostream& os, itk::Indent indent) const;
......@@ -135,7 +135,6 @@ private:
itk::FixedArray<unsigned int, VImageDimension> m_SplitsPerDimension;
unsigned int m_TileDimension;
unsigned int m_TileSizeAlignment;
unsigned int m_TileHint;
};
} // end namespace otb
......
......@@ -33,23 +33,8 @@ ImageRegionSquareTileSplitter<VImageDimension>
unsigned int theoricalNbPixelPerTile = region.GetNumberOfPixels() / requestedNumber;
unsigned int theoricalTileDimension = static_cast<unsigned int> (vcl_sqrt(static_cast<double>(theoricalNbPixelPerTile)) );
m_TileDimension = m_TileHint;
// If we have less than one jpeg 2000 tile, split in sub-tiles
if(theoricalTileDimension < m_TileHint)
{
while(m_TileDimension > theoricalTileDimension)
{
m_TileDimension/=2;
}
}
else
{
while(2*m_TileDimension < theoricalTileDimension)
{
m_TileDimension*=2;
}
}
// Take the next multiple of m_TileSizeAlignment (eventually generate more splits than requested)
m_TileDimension = (theoricalTileDimension + m_TileSizeAlignment - 1) / m_TileSizeAlignment * m_TileSizeAlignment;
// Minimal tile size is m_TileSizeAlignment * m_TileSizeAlignment
if (m_TileDimension < m_TileSizeAlignment)
......@@ -93,55 +78,26 @@ ImageRegionSquareTileSplitter<VImageDimension>
itkExceptionMacro("Asked for split number " << i << " but region contains only " << numPieces << " splits");
}
// First, find the megatile index
unsigned int tilesPerMegaTilesPerDim = m_TileHint / m_TileDimension;
if(tilesPerMegaTilesPerDim == 0)
{
tilesPerMegaTilesPerDim = 1;
}
// Can't use more tiles than the number of splits per dim
if (tilesPerMegaTilesPerDim > m_SplitsPerDimension[0])
tilesPerMegaTilesPerDim = m_SplitsPerDimension[0];
if (tilesPerMegaTilesPerDim > m_SplitsPerDimension[1])
tilesPerMegaTilesPerDim = m_SplitsPerDimension[1];
unsigned int tilesPerMegaTiles = tilesPerMegaTilesPerDim*tilesPerMegaTilesPerDim;
unsigned int remaining = i / tilesPerMegaTiles;
// Compute the split index in the streaming grid
unsigned int remaining = i;
for (unsigned int j = VImageDimension - 1; j > 0; --j)
{
splitIndex[j] = tilesPerMegaTilesPerDim * remaining / (m_SplitsPerDimension[VImageDimension - 1 - j] / tilesPerMegaTilesPerDim);
remaining = remaining % (m_SplitsPerDimension[VImageDimension - 1 - j] / tilesPerMegaTilesPerDim);
splitIndex[j] = remaining / m_SplitsPerDimension[VImageDimension - 1 - j];
remaining = remaining % m_SplitsPerDimension[VImageDimension - 1 - j];
}
splitIndex[0] = tilesPerMegaTilesPerDim * remaining;
splitIndex[0] = remaining;
// Now splitIndex contains the megaTile index
remaining = i % tilesPerMegaTiles;
for (unsigned int j = VImageDimension - 1; j > 0; --j)
{
splitIndex[j] += remaining / tilesPerMegaTilesPerDim;
remaining = remaining % (tilesPerMegaTilesPerDim);
}
splitIndex[0]+= remaining;
// Now split index contains the tile index
// Transform the split index to the actual coordinates
for (unsigned int j = 0; j < VImageDimension; ++j)
{
splitRegion.SetIndex(j, region.GetIndex(j) + m_TileDimension * splitIndex[j]);
splitRegion.SetSize(j, m_TileDimension);
}
// Handle the borders
splitRegion.Crop(region);
return splitRegion;
// Handle the borders
splitRegion.Crop(region);
return splitRegion;
}
/**
......
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