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
0bd6724f
Commit
0bd6724f
authored
Aug 10, 2016
by
remicres
Browse files
REFAC: clean functions prototypes (remove some unused variables)
parent
972a814a
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/lsgrmController.h
View file @
0bd6724f
...
...
@@ -3,6 +3,7 @@
#include "lsrmGetInternalMemory.h"
#include "lsgrmSplitter.h"
#include "lsgrmGraphOperations.h"
#include "itkMacro.h"
namespace
lsgrm
{
...
...
@@ -28,7 +29,8 @@ namespace lsgrm
void
SetTemporaryDirectory
(
const
std
::
string
&
str
);
void
SetTileWidth
(
const
unsigned
int
v
);
void
SetTileHeight
(
const
unsigned
int
v
);
void
SetNumberOfFirstIterations
(
const
unsigned
int
v
);
void
SetNumberOfFirstIterations
(
const
unsigned
int
v
);
void
SetNumberOfIterations
(
const
unsigned
int
v
);
void
SetSpecificParameters
(
const
SegmentationParameterType
&
params
);
void
SetThreshold
(
const
float
&
t
);
void
SetInternalMemoryAvailable
(
long
long
unsigned
int
v
);
// expecting a value in Mbytes.
...
...
@@ -36,6 +38,8 @@ namespace lsgrm
typename
LabelImageType
::
Pointer
GetLabeledClusteredOutput
();
itkGetMacro
(
ListOfTemporaryFiles
,
std
::
vector
<
std
::
string
>
);
private:
void
GetAutomaticConfiguration
();
...
...
@@ -55,13 +59,15 @@ namespace lsgrm
/* Internal attribute members.*/
unsigned
int
m_NbTilesX
;
unsigned
int
m_NbTilesY
;
unsigned
int
m_NumberOfFirstIterations
;
unsigned
int
m_NumberOfFirstIterations
;
unsigned
int
m_NumberOfIterations
;
unsigned
int
m_Margin
;
unsigned
int
m_TileWidth
;
unsigned
int
m_TileHeight
;
bool
m_AutomaticTilingLayout
;
std
::
vector
<
ProcessingTile
>
m_Tiles
;
std
::
vector
<
std
::
string
>
m_ListOfTemporaryFiles
;
typename
LabelImageType
::
Pointer
m_LabelImage
;
};
...
...
include/lsgrmController.txx
View file @
0bd6724f
...
...
@@ -19,8 +19,12 @@ template<class TSegmenter>
void Controller<TSegmenter>::RunSegmentation()
{
// TODO: smarter value?
const unsigned int numberOfIterationsForPartialSegmentations = 3;
unsigned int numberOfIterations = m_NumberOfIterations;
// Automatic procedure
if(m_Memory
< 1
)
if(m_Memory
== 0
)
{
this->GetAutomaticConfiguration();
}
...
...
@@ -45,17 +49,18 @@ void Controller<TSegmenter>::RunSegmentation()
m_SpecificParameters,
m_Threshold,
m_NumberOfFirstIterations,
3
,
numberOfIterationsForPartialSegmentations
,
m_Tiles,
m_NbTilesX,
m_NbTilesY,
m_TileWidth,
m_TileHeight,
m_InputImage->GetLargestPossibleRegion().GetSize()[0],
m_InputImage->GetLargestPossibleRegion().GetSize()[1],
m_TemporaryDirectory,
isFusion);
// Update the given number of iterations
numberOfIterations -= m_NumberOfFirstIterations;
// Gathering useful variables
GatherUsefulVariables(accumulatedMemory, isFusion);
...
...
@@ -69,7 +74,7 @@ void Controller<TSegmenter>::RunSegmentation()
accumulatedMemory = RunPartialSegmentation<TSegmenter>(
m_SpecificParameters,
m_Threshold,
3
,
numberOfIterationsForPartialSegmentations
,
m_Tiles,
m_TemporaryDirectory,
m_NbTilesX,
...
...
@@ -79,6 +84,9 @@ void Controller<TSegmenter>::RunSegmentation()
m_InputImage->GetNumberOfComponentsPerPixel(),
isFusion);
// Update the given number of iterations
numberOfIterations -= numberOfIterationsForPartialSegmentations;
// Gathering useful variables
GatherUsefulVariables(accumulatedMemory, isFusion);
...
...
@@ -104,7 +112,8 @@ void Controller<TSegmenter>::RunSegmentation()
m_NbTilesY,
m_InputImage->GetLargestPossibleRegion().GetSize()[0],
m_InputImage->GetLargestPossibleRegion().GetSize()[1],
m_InputImage->GetNumberOfComponentsPerPixel());
m_InputImage->GetNumberOfComponentsPerPixel(),
numberOfIterations);
// ShowTime(t);
...
...
@@ -280,6 +289,12 @@ void Controller<TSegmenter>::SetNumberOfFirstIterations(const unsigned int v)
m_Margin = static_cast<unsigned int>(pow(2, m_NumberOfFirstIterations + 1) - 2);// 2^{n+1}-2
}
template<class TSegmenter>
void Controller<TSegmenter>::SetNumberOfIterations(const unsigned int v)
{
m_NumberOfIterations = v;
}
template<class TSegmenter>
void Controller<TSegmenter>::SetSpecificParameters(const SegmentationParameterType& params)
{
...
...
include/lsgrmGraphOperations.h
View file @
0bd6724f
...
...
@@ -35,7 +35,8 @@ MergeAllGraphsAndAchieveSegmentation(
const
unsigned
int
nbTilesY
,
const
unsigned
int
imageWidth
,
const
unsigned
int
imageHeight
,
const
unsigned
int
imageBands
);
const
unsigned
int
imageBands
,
unsigned
int
numberOfIterations
);
template
<
class
TSegmenter
>
long
long
unsigned
int
RunFirstPartialSegmentation
(
...
...
@@ -49,8 +50,6 @@ long long unsigned int RunFirstPartialSegmentation(
const
unsigned
int
nbTilesY
,
const
unsigned
int
tileWidth
,
const
unsigned
int
tileHeight
,
const
unsigned
int
imageWidth
,
const
unsigned
int
imageHeight
,
const
std
::
string
&
tmpDir
,
bool
&
isFusion
);
...
...
include/lsgrmGraphOperations.txx
View file @
0bd6724f
...
...
@@ -32,7 +32,8 @@ MergeAllGraphsAndAchieveSegmentation(
const unsigned int nbTilesY,
const unsigned int imageWidth,
const unsigned int imageHeight,
const unsigned int imageBands)
const unsigned int imageBands,
unsigned int numberOfIterations)
{
// TODO parallelize this ...
...
...
@@ -104,7 +105,7 @@ MergeAllGraphsAndAchieveSegmentation(
segmenter.SetParam(params);
segmenter.SetThreshold(threshold);
segmenter.SetDoBFSegmentation(true);
segmenter.SetNumberOfIterations(
75
);
segmenter.SetNumberOfIterations(
numberOfIterations
);
lsrm::GraphOperations<TSegmenter>::PerfomAllIterationsWithLMBFAndConstThreshold(segmenter);
...
...
@@ -143,8 +144,9 @@ long long unsigned int RunPartialSegmentation(const typename TSegmenter::Paramet
if (MyTurn(row*nbTilesX + col))
{
TSegmenter segmenter;
std::cout << "
T
ile " << row << " " << col << std::endl;
std::cout << "
Processing t
ile " << row << "
,
" << col << std::endl;
std::cout << "\tLoad graph..." << std::endl;
// Load the graph
nodesPath = tmpDir + "tile_nodes_" + std::to_string(row) + "_" + std::to_string(col) + ".bin";
edgesPath = tmpDir + "tile_edges_" + std::to_string(row) + "_" + std::to_string(col) + ".bin";
...
...
@@ -692,13 +694,13 @@ long long unsigned int RunFirstPartialSegmentation(
const unsigned int nbTilesY,
const unsigned int tileWidth,
const unsigned int tileHeight,
const unsigned int imageWidth,
const unsigned int imageHeight,
const std::string& tmpDir,
bool& isFusion)
{
using ImageType = typename TSegmenter::ImageType;
const unsigned int imageWidth = inputPtr->GetLargestPossibleRegion().GetSize()[0];
const unsigned int imageHeight = inputPtr->GetLargestPossibleRegion().GetSize()[1];
long long unsigned int accumulatedMemory = 0;
isFusion = false;
...
...
@@ -736,7 +738,7 @@ long long unsigned int RunFirstPartialSegmentation(
isFusion = true;
// Rescale the graph to be in the reference of the image
std::cout << "\tRescal
e
graph" << std::endl;
std::cout << "\tRescal
ing
graph
...
" << std::endl;
RescaleGraph<TSegmenter>(segmenter.m_Graph,
tiles[row*nbTilesX + col],
row,
...
...
@@ -746,19 +748,20 @@ long long unsigned int RunFirstPartialSegmentation(
imageWidth);
// Remove unstable segments
std::cout << "\tRemoving unstable segments" << std::endl;
std::cout << "\tRemoving unstable segments
...
" << std::endl;
RemoveUnstableSegments<TSegmenter>(segmenter.m_Graph, tiles[row*nbTilesX + col], imageWidth);
// Retrieve the amount of memory to store this graph
std::cout << "\t
G
et graph memory" << std::endl;
std::cout << "\t
R
et
rieving
graph memory
...
" << std::endl;
accumulatedMemory += GetGraphMemory<TSegmenter>(segmenter.m_Graph);
// Write graph to temporay directory (warning specific to Baatz & Schape !!!)
std::cout << "\tWrit
e
graph" << std::endl;
std::cout << "\tWrit
ing
graph
...
" << std::endl;
WriteGraph<TSegmenter>(segmenter.m_Graph, tmpDir, row, col);
// Extract stability margin for all borders different from 0 imageWidth-1 et imageHeight -1
// and write them to the stability margin
std::cout << "\tComputing stability margin..." << std::endl;
{
std::unordered_map<typename TSegmenter::NodePointerType, unsigned int> borderNodeMap;
...
...
@@ -1230,34 +1233,37 @@ void RescaleGraph(typename TSegmenter::GraphType& graph,
unsigned int rowNodeTile, colNodeTile;
unsigned int rowNodeImg, colNodeImg;
unsigned int currTileWidth = tile.columns[1] - tile.columns[0] + 1;
unsigned int diffHeightMargin
= tile.margin[
0
];
currTileWidth += tile.margin[
1
];
unsigned int diff
Width
Margin = tile.margin[
3
];
currTileWidth +
= tile.margin[3];
//
unsigned int currTileWidth = tile.columns[1] - tile.columns[0] + 1;
// currTileWidth +
= tile.margin[
1
];
//
currTileWidth += tile.margin[
3
];
//
unsigned int diff
Height
Margin = tile.margin[
0
];
// unsigned int diffWidthMargin
= tile.margin[3];
unsigned int count = 0;
for(auto& node : graph.m_Nodes)
{
// Row of the start pixel of the node
rowNodeTile = node->m_Id / currTileWidth;
// Col of the start pixel of the node
colNodeTile = node->m_Id % currTileWidth;
// Row of the start pixel of the node in the image
rowNodeImg = rowTile * tileHeight + rowNodeTile - diffHeightMargin;
// Col of the start pixel of the node in the image
colNodeImg = colTile * tileWidth + colNodeTile - diffWidthMargin;
// New id of the node in the image
// // Row of the start pixel of the node
// rowNodeTile = node->m_Id / currTileWidth;
// // Col of the start pixel of the node
// colNodeTile = node->m_Id % currTileWidth;
//
// // Row of the start pixel of the node in the image
// rowNodeImg = rowTile * tileHeight + rowNodeTile - diffHeightMargin;
// // Col of the start pixel of the node in the image
// colNodeImg = colTile * tileWidth + colNodeTile - diffWidthMargin;
//
// node->m_Id = rowNodeImg * imageWidth + colNodeImg;
rowNodeTile = node->m_Id / tile.region.GetSize()[0];
colNodeTile = node->m_Id % tile.region.GetSize()[0];
rowNodeImg = rowTile * tileHeight + rowNodeTile - tile.margin[0];
colNodeImg = colTile * tileWidth + colNodeTile - tile.margin[3];
node->m_Id = rowNodeImg * imageWidth + colNodeImg;
// Change also its bounding box
node->m_Bbox.m_UX = colTile * tileWidth + node->m_Bbox.m_UX - diffWidthMargin;
node->m_Bbox.m_UY = rowTile * tileHeight + node->m_Bbox.m_UY - diffHeightMargin;
++count;
node->m_Bbox.m_UX = colTile * tileWidth + node->m_Bbox.m_UX - tile.margin[3];
node->m_Bbox.m_UY = rowTile * tileHeight + node->m_Bbox.m_UY - tile.margin[0];
}
}
}
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