Commit ca4c3411 authored by remicres's avatar remicres

ENH: Tiles contain temporary file names related to graphs

parent f863dd07
......@@ -9,13 +9,13 @@ namespace lsgrm
// Split with the OTB library
template <class TInputImage>
void SplitOTBImage(TInputImage * imagePtr, // input image
std::vector<ProcessingTile> SplitOTBImage(TInputImage * imagePtr, // input image
unsigned int& tileWidth, // width of the tile
unsigned int& tileHeight, // height of the tile
const unsigned int margin, // stability margin
unsigned int &nbTilesX,
unsigned int &nbTilesY,
std::vector<ProcessingTile> &m_Tiles);
std::string temporaryFilesPrefix);
} // end of namespace lsgrm
......
......@@ -22,15 +22,17 @@ enum NeighborhoodRelativePosition{
};
template <class TInputImage>
void SplitOTBImage(TInputImage * imagePtr, // input image
std::vector<ProcessingTile> SplitOTBImage(TInputImage * imagePtr, // input image
unsigned int& tileWidth, // width of the tile
unsigned int& tileHeight, // height of the tile
const unsigned int margin, // stability margin
unsigned int &nbTilesX,
unsigned int &nbTilesY,
std::vector<ProcessingTile> &m_Tiles)
std::string temporaryFilesPrefix)
{
std::vector<ProcessingTile> tiles;
// Image size
auto imageWidth = imagePtr->GetLargestPossibleRegion().GetSize()[0];
auto imageHeight = imagePtr->GetLargestPossibleRegion().GetSize()[1];
......@@ -40,7 +42,7 @@ void SplitOTBImage(TInputImage * imagePtr, // input image
unsigned int sizeX, sizeY; // Size of the tiles.
/* Loop over the tiles*/
m_Tiles.assign(nbTilesX * nbTilesY, ProcessingTile());
tiles.assign(nbTilesX * nbTilesY, ProcessingTile());
unsigned int i = 0;
for(unsigned int row = 0; row < nbTilesY; ++row)
{
......@@ -66,103 +68,110 @@ void SplitOTBImage(TInputImage * imagePtr, // input image
/* Margin at the top ? */
if( row > 0 )
{
m_Tiles[i].margin[POS_TOP] = margin;
m_Tiles[i].rows[0] = row * tileHeight;
m_Tiles[i].tileNeighbors[NBH_TOP] = i - nbTilesX;
tiles[i].margin[POS_TOP] = margin;
tiles[i].rows[0] = row * tileHeight;
tiles[i].tileNeighbors[NBH_TOP] = i - nbTilesX;
}
else
{
// Tile is on the top row --> no top margin
m_Tiles[i].margin[POS_TOP] = 0;
m_Tiles[i].rows[0] = 0;
m_Tiles[i].tileNeighbors[NBH_TOP] = -1;
tiles[i].margin[POS_TOP] = 0;
tiles[i].rows[0] = 0;
tiles[i].tileNeighbors[NBH_TOP] = -1;
}
/* Margin at the right */
if( col < nbTilesX - 1 )
{
m_Tiles[i].margin[POS_RIGHT] = margin;
m_Tiles[i].columns[1] = col * tileWidth + sizeX - 1; //sizeX
m_Tiles[i].tileNeighbors[NBH_RIGHT] = i+1;
tiles[i].margin[POS_RIGHT] = margin;
tiles[i].columns[1] = col * tileWidth + sizeX - 1; //sizeX
tiles[i].tileNeighbors[NBH_RIGHT] = i+1;
}
else
{
// Tile is on the right column --> no right margin
m_Tiles[i].margin[POS_RIGHT] = 0;
m_Tiles[i].columns[1] = imageWidth - 1;
m_Tiles[i].tileNeighbors[NBH_RIGHT] = -1;
tiles[i].margin[POS_RIGHT] = 0;
tiles[i].columns[1] = imageWidth - 1;
tiles[i].tileNeighbors[NBH_RIGHT] = -1;
}
/* Margin at the bottom */
if( row < nbTilesY - 1)
{
m_Tiles[i].margin[POS_BOTTOM] = margin;
m_Tiles[i].rows[1] = row * tileHeight + sizeY - 1; // sizeY
m_Tiles[i].tileNeighbors[NBH_BOTTOM] = i + nbTilesX;
tiles[i].margin[POS_BOTTOM] = margin;
tiles[i].rows[1] = row * tileHeight + sizeY - 1; // sizeY
tiles[i].tileNeighbors[NBH_BOTTOM] = i + nbTilesX;
}
else
{
// Tile is on the bottom --> no bottom margin
m_Tiles[i].margin[POS_BOTTOM] = 0;
m_Tiles[i].rows[1] = imageHeight - 1;
m_Tiles[i].tileNeighbors[NBH_BOTTOM] = -1;
tiles[i].margin[POS_BOTTOM] = 0;
tiles[i].rows[1] = imageHeight - 1;
tiles[i].tileNeighbors[NBH_BOTTOM] = -1;
}
/* Margin at the left */
if( col > 0 )
{
m_Tiles[i].margin[POS_LEFT] = margin;
m_Tiles[i].columns[0] = col * tileWidth;
m_Tiles[i].tileNeighbors[NBH_LEFT] = i-1;
tiles[i].margin[POS_LEFT] = margin;
tiles[i].columns[0] = col * tileWidth;
tiles[i].tileNeighbors[NBH_LEFT] = i-1;
}
else
{
// Tile is on the left --> no left margin
m_Tiles[i].margin[POS_LEFT] = 0;
m_Tiles[i].columns[0] = 0;
m_Tiles[i].tileNeighbors[NBH_LEFT] = -1;
tiles[i].margin[POS_LEFT] = 0;
tiles[i].columns[0] = 0;
tiles[i].tileNeighbors[NBH_LEFT] = -1;
}
/* Store the tile region */
typename TInputImage::IndexType index;
index[0] = startX - m_Tiles[i].margin[POS_LEFT];
index[1] = startY - m_Tiles[i].margin[POS_TOP];
index[0] = startX - tiles[i].margin[POS_LEFT];
index[1] = startY - tiles[i].margin[POS_TOP];
typename TInputImage::SizeType size;
size[0] = sizeX + m_Tiles[i].margin[POS_LEFT] + m_Tiles[i].margin[POS_RIGHT];
size[1] = sizeY + m_Tiles[i].margin[POS_TOP] + m_Tiles[i].margin[POS_BOTTOM];
size[0] = sizeX + tiles[i].margin[POS_LEFT] + tiles[i].margin[POS_RIGHT];
size[1] = sizeY + tiles[i].margin[POS_TOP] + tiles[i].margin[POS_BOTTOM];
typename TInputImage::RegionType region(index, size);
m_Tiles[i].region = region;
tiles[i].region = region;
std::cout << "Tile " << i << ": start at " << index << " with size " << size << std::endl;
/* Is there a neighbor at the rop right */
if(row > 0 && col < nbTilesX - 1)
m_Tiles[i].tileNeighbors[NBH_TOP_RIGHT] = i - nbTilesX + 1;
tiles[i].tileNeighbors[NBH_TOP_RIGHT] = i - nbTilesX + 1;
else
m_Tiles[i].tileNeighbors[NBH_TOP_RIGHT] = -1;
tiles[i].tileNeighbors[NBH_TOP_RIGHT] = -1;
/* Is there a neighbor at the bottom right */
if(col < nbTilesX - 1 && row < nbTilesY - 1)
m_Tiles[i].tileNeighbors[NBH_BOTTOM_RIGHT] = i + nbTilesX + 1;
tiles[i].tileNeighbors[NBH_BOTTOM_RIGHT] = i + nbTilesX + 1;
else
m_Tiles[i].tileNeighbors[NBH_BOTTOM_RIGHT] = -1;
tiles[i].tileNeighbors[NBH_BOTTOM_RIGHT] = -1;
/* Is there a neighbor at the bottom left */
if(row < nbTilesY - 1 && col > 0)
m_Tiles[i].tileNeighbors[NBH_BOTTOM_LEFT] = i + nbTilesX - 1;
tiles[i].tileNeighbors[NBH_BOTTOM_LEFT] = i + nbTilesX - 1;
else
m_Tiles[i].tileNeighbors[NBH_BOTTOM_LEFT] = -1;
tiles[i].tileNeighbors[NBH_BOTTOM_LEFT] = -1;
/* Is there a neighbor at the top left */
if(col > 0 && row > 0)
m_Tiles[i].tileNeighbors[NBH_TOP_LEFT] = i - nbTilesX - 1;
tiles[i].tileNeighbors[NBH_TOP_LEFT] = i - nbTilesX - 1;
else
m_Tiles[i].tileNeighbors[NBH_TOP_LEFT] = -1;
tiles[i].tileNeighbors[NBH_TOP_LEFT] = -1;
std::string suffix = std::to_string(row) + "_" + std::to_string(col) + ".bin";
tiles[i].nodeFileName = temporaryFilesPrefix + "_node_" + suffix;
tiles[i].edgeFileName = temporaryFilesPrefix + "_edge_" + suffix;
tiles[i].nodeMarginFileName = temporaryFilesPrefix + "_nodeMargin_" + suffix;
tiles[i].edgeMarginFileName = temporaryFilesPrefix + "_edgeMargin_" + suffix;
i++;
} // end for(unsigned int col = 0; col < nbTilesX; ++col)
} // for(unsigned int row = 0; row < nbTilesY; ++row)
return tiles;
}
} // end of namespace lsgrm
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