Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Cresson Remi
LSGRM
Commits
ca4c3411
Commit
ca4c3411
authored
Aug 23, 2016
by
remicres
Browse files
ENH: Tiles contain temporary file names related to graphs
parent
f863dd07
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/lsgrmSplitter.h
View file @
ca4c3411
...
...
@@ -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
...
...
include/lsgrmSplitter.txx
View file @
ca4c3411
...
...
@@ -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_T
iles.assign(nbTilesX * nbTilesY, ProcessingTile());
t
iles.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_T
iles[i].margin[POS_TOP] = margin;
m_T
iles[i].rows[0] = row * tileHeight;
m_T
iles[i].tileNeighbors[NBH_TOP] = i - nbTilesX;
t
iles[i].margin[POS_TOP] = margin;
t
iles[i].rows[0] = row * tileHeight;
t
iles[i].tileNeighbors[NBH_TOP] = i - nbTilesX;
}
else
{
// Tile is on the top row --> no top margin
m_T
iles[i].margin[POS_TOP] = 0;
m_T
iles[i].rows[0] = 0;
m_T
iles[i].tileNeighbors[NBH_TOP] = -1;
t
iles[i].margin[POS_TOP] = 0;
t
iles[i].rows[0] = 0;
t
iles[i].tileNeighbors[NBH_TOP] = -1;
}
/* Margin at the right */
if( col < nbTilesX - 1 )
{
m_T
iles[i].margin[POS_RIGHT] = margin;
m_T
iles[i].columns[1] = col * tileWidth + sizeX - 1; //sizeX
m_T
iles[i].tileNeighbors[NBH_RIGHT] = i+1;
t
iles[i].margin[POS_RIGHT] = margin;
t
iles[i].columns[1] = col * tileWidth + sizeX - 1; //sizeX
t
iles[i].tileNeighbors[NBH_RIGHT] = i+1;
}
else
{
// Tile is on the right column --> no right margin
m_T
iles[i].margin[POS_RIGHT] = 0;
m_T
iles[i].columns[1] = imageWidth - 1;
m_T
iles[i].tileNeighbors[NBH_RIGHT] = -1;
t
iles[i].margin[POS_RIGHT] = 0;
t
iles[i].columns[1] = imageWidth - 1;
t
iles[i].tileNeighbors[NBH_RIGHT] = -1;
}
/* Margin at the bottom */
if( row < nbTilesY - 1)
{
m_T
iles[i].margin[POS_BOTTOM] = margin;
m_T
iles[i].rows[1] = row * tileHeight + sizeY - 1; // sizeY
m_T
iles[i].tileNeighbors[NBH_BOTTOM] = i + nbTilesX;
t
iles[i].margin[POS_BOTTOM] = margin;
t
iles[i].rows[1] = row * tileHeight + sizeY - 1; // sizeY
t
iles[i].tileNeighbors[NBH_BOTTOM] = i + nbTilesX;
}
else
{
// Tile is on the bottom --> no bottom margin
m_T
iles[i].margin[POS_BOTTOM] = 0;
m_T
iles[i].rows[1] = imageHeight - 1;
m_T
iles[i].tileNeighbors[NBH_BOTTOM] = -1;
t
iles[i].margin[POS_BOTTOM] = 0;
t
iles[i].rows[1] = imageHeight - 1;
t
iles[i].tileNeighbors[NBH_BOTTOM] = -1;
}
/* Margin at the left */
if( col > 0 )
{
m_T
iles[i].margin[POS_LEFT] = margin;
m_T
iles[i].columns[0] = col * tileWidth;
m_T
iles[i].tileNeighbors[NBH_LEFT] = i-1;
t
iles[i].margin[POS_LEFT] = margin;
t
iles[i].columns[0] = col * tileWidth;
t
iles[i].tileNeighbors[NBH_LEFT] = i-1;
}
else
{
// Tile is on the left --> no left margin
m_T
iles[i].margin[POS_LEFT] = 0;
m_T
iles[i].columns[0] = 0;
m_T
iles[i].tileNeighbors[NBH_LEFT] = -1;
t
iles[i].margin[POS_LEFT] = 0;
t
iles[i].columns[0] = 0;
t
iles[i].tileNeighbors[NBH_LEFT] = -1;
}
/* Store the tile region */
typename TInputImage::IndexType index;
index[0] = startX -
m_T
iles[i].margin[POS_LEFT];
index[1] = startY -
m_T
iles[i].margin[POS_TOP];
index[0] = startX -
t
iles[i].margin[POS_LEFT];
index[1] = startY -
t
iles[i].margin[POS_TOP];
typename TInputImage::SizeType size;
size[0] = sizeX +
m_T
iles[i].margin[POS_LEFT] +
m_T
iles[i].margin[POS_RIGHT];
size[1] = sizeY +
m_T
iles[i].margin[POS_TOP] +
m_T
iles[i].margin[POS_BOTTOM];
size[0] = sizeX +
t
iles[i].margin[POS_LEFT] +
t
iles[i].margin[POS_RIGHT];
size[1] = sizeY +
t
iles[i].margin[POS_TOP] +
t
iles[i].margin[POS_BOTTOM];
typename TInputImage::RegionType region(index, size);
m_T
iles[i].region = region;
t
iles[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_T
iles[i].tileNeighbors[NBH_TOP_RIGHT] = i - nbTilesX + 1;
t
iles[i].tileNeighbors[NBH_TOP_RIGHT] = i - nbTilesX + 1;
else
m_T
iles[i].tileNeighbors[NBH_TOP_RIGHT] = -1;
t
iles[i].tileNeighbors[NBH_TOP_RIGHT] = -1;
/* Is there a neighbor at the bottom right */
if(col < nbTilesX - 1 && row < nbTilesY - 1)
m_T
iles[i].tileNeighbors[NBH_BOTTOM_RIGHT] = i + nbTilesX + 1;
t
iles[i].tileNeighbors[NBH_BOTTOM_RIGHT] = i + nbTilesX + 1;
else
m_T
iles[i].tileNeighbors[NBH_BOTTOM_RIGHT] = -1;
t
iles[i].tileNeighbors[NBH_BOTTOM_RIGHT] = -1;
/* Is there a neighbor at the bottom left */
if(row < nbTilesY - 1 && col > 0)
m_T
iles[i].tileNeighbors[NBH_BOTTOM_LEFT] = i + nbTilesX - 1;
t
iles[i].tileNeighbors[NBH_BOTTOM_LEFT] = i + nbTilesX - 1;
else
m_T
iles[i].tileNeighbors[NBH_BOTTOM_LEFT] = -1;
t
iles[i].tileNeighbors[NBH_BOTTOM_LEFT] = -1;
/* Is there a neighbor at the top left */
if(col > 0 && row > 0)
m_T
iles[i].tileNeighbors[NBH_TOP_LEFT] = i - nbTilesX - 1;
t
iles[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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment