Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
LSGRM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cresson Remi
LSGRM
Commits
aa288e4d
Commit
aa288e4d
authored
Aug 24, 2016
by
remicres
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REFAC: KWStyle
parent
a34732ef
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
235 additions
and
244 deletions
+235
-244
app/otbLSGRM.cxx
app/otbLSGRM.cxx
+18
-33
include/lsgrmBaatzSegmenter.txx
include/lsgrmBaatzSegmenter.txx
+44
-44
include/lsgrmController.txx
include/lsgrmController.txx
+13
-7
include/lsgrmFullLambdaScheduleSegmenter.txx
include/lsgrmFullLambdaScheduleSegmenter.txx
+35
-35
include/lsgrmGraphOperations.txx
include/lsgrmGraphOperations.txx
+5
-5
include/lsgrmGraphToOtbImage.h
include/lsgrmGraphToOtbImage.h
+19
-19
include/lsgrmGraphToOtbImage.txx
include/lsgrmGraphToOtbImage.txx
+60
-60
include/lsgrmSplitter.txx
include/lsgrmSplitter.txx
+6
-6
include/lsgrmSpringSegmenter.txx
include/lsgrmSpringSegmenter.txx
+35
-35
No files found.
app/otbLSGRM.cxx
View file @
aa288e4d
...
...
@@ -10,7 +10,7 @@
#include "itkFixedArray.h"
#include "itkImageSource.h"
// GRM
//
LS
GRM
#include <iostream>
#include "lsgrmBaatzSegmenter.h"
#include "lsgrmSpringSegmenter.h"
...
...
@@ -44,9 +44,6 @@ public:
typedef
lsgrm
::
BaatzSegmenter
<
ImageType
>
BaatzSegmenterType
;
typedef
lsgrm
::
SpringSegmenter
<
ImageType
>
SpringSegmenterType
;
typedef
lsgrm
::
FullLambdaScheduleSegmenter
<
ImageType
>
FLSSegmenterType
;
typedef
lsgrm
::
Controller
<
BaatzSegmenterType
>
BaatzControllerType
;
typedef
lsgrm
::
Controller
<
SpringSegmenterType
>
SpringControllerType
;
typedef
lsgrm
::
Controller
<
FLSSegmenterType
>
FLSControllerType
;
private:
...
...
@@ -69,8 +66,8 @@ private:
void
DoInit
()
{
SetName
(
"GenericRegionMerging"
);
SetDescription
(
"This application allows to use the Generic Region Merging library "
"(GRM) and provides currently 3 homogeneity criteria: Euclidean Distance, "
SetDescription
(
"This application allows to use the
Large Scale
Generic Region Merging library "
"(
LS
GRM) and provides currently 3 homogeneity criteria: Euclidean Distance, "
"Full Lambda Schedule and Baatz & Schape criterion."
);
// Input and Output images
...
...
@@ -114,7 +111,6 @@ private:
{
}
/*
* Return a prefix for temporary files
*/
...
...
@@ -143,9 +139,16 @@ private:
/*
* This function sets the generic parameters of a controller and runs the segmentation
*/
template
<
class
TController
>
UInt32ImageType
::
Pointer
SetGenericParametersAndRunSegmentation
(
typename
TController
::
Pointer
&
controller
)
{
template
<
class
TSegmenter
>
UInt32ImageType
::
Pointer
SetGenericParametersAndRunSegmentation
(
const
typename
TSegmenter
::
ParamType
params
){
// Instantiate the controller
typedef
typename
lsgrm
::
Controller
<
TSegmenter
>
ControlerType
;
typename
ControlerType
::
Pointer
controller
=
ControlerType
::
New
();
// Set specific parameters
controller
->
SetSpecificParameters
(
params
);
// Set input image
controller
->
SetInputImage
(
GetParameterFloatVectorImage
(
"in"
));
...
...
@@ -195,8 +198,6 @@ private:
return
controller
->
GetLabeledClusteredOutput
();
}
void
DoExecute
()
{
/*
...
...
@@ -214,33 +215,20 @@ private:
int
inputCriterion
=
GetParameterInt
(
"criterion"
);
if
(
inputCriterion
==
CRITERION_BAATZ
)
{
// Baatz controller
BaatzControllerType
::
Pointer
baatzController
=
BaatzControllerType
::
New
();
// Specific parameters
grm
::
BaatzParam
params
;
params
.
m_SpectralWeight
=
GetParameterFloat
(
"criterion.bs.cw"
);
params
.
m_ShapeWeight
=
GetParameterFloat
(
"criterion.bs.sw"
);
baatzController
->
SetSpecificParameters
(
params
);
// Run segmentation
labelImage
=
SetGenericParametersAndRunSegmentation
<
BaatzControllerType
>
(
baatzController
);
labelImage
=
SetGenericParametersAndRunSegmentation
<
BaatzSegmenterType
>
(
params
);
}
else
if
(
inputCriterion
==
CRITERION_SPRING
)
{
// Spring controller
SpringControllerType
::
Pointer
springController
=
SpringControllerType
::
New
();
// Run segmentation
labelImage
=
SetGenericParametersAndRunSegmentation
<
SpringControllerType
>
(
springController
);
grm
::
SpringParam
params
;
labelImage
=
SetGenericParametersAndRunSegmentation
<
SpringSegmenterType
>
(
params
);
}
else
if
(
inputCriterion
==
CRITERION_FLS
)
{
// Full Lambda Schedule (FLS) controller
FLSControllerType
::
Pointer
flsController
=
FLSControllerType
::
New
();
// Run segmentation
labelImage
=
SetGenericParametersAndRunSegmentation
<
FLSControllerType
>
(
flsController
);
grm
::
FLSParam
params
;
labelImage
=
SetGenericParametersAndRunSegmentation
<
FLSSegmenterType
>
(
params
);
}
else
{
...
...
@@ -253,7 +241,6 @@ private:
labelImage
->
SetSpacing
(
inputImage
->
GetSpacing
());
SetParameterOutputImage
<
UInt32ImageType
>
(
"out"
,
labelImage
);
}
void
AfterExecuteAndWriteOutputs
()
...
...
@@ -275,6 +262,4 @@ private:
}
// end of namespace wrapper
}
// end of namespace otb
OTB_APPLICATION_EXPORT
(
otb
::
Wrapper
::
LSGRM
)
include/lsgrmBaatzSegmenter.txx
View file @
aa288e4d
...
...
@@ -6,56 +6,56 @@
namespace lsgrm
{
template<class TImage>
void
BaatzSegmenter<TImage>::WriteSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands = node->m_Means.size();
fwrite(&(bands), sizeof(bands), 1, nodeStream);
for(unsigned int b = 0; b < node->m_Means.size(); b++)
{
fwrite(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
fwrite(&(node->m_SquareMeans[b]), sizeof(node->m_SquareMeans[b]), 1, nodeStream);
fwrite(&(node->m_SpectralSum[b]), sizeof(node->m_SpectralSum[b]), 1, nodeStream);
fwrite(&(node->m_Std[b]), sizeof(node->m_Std[b]), 1, nodeStream);
}
}
template<class TImage>
void
BaatzSegmenter<TImage>::ReadSpecificAttributes(NodePointerType node, FILE * nodeStream)
template<class TImage>
void
BaatzSegmenter<TImage>::WriteSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands = node->m_Means.size();
fwrite(&(bands), sizeof(bands), 1, nodeStream);
for(unsigned int b = 0; b < node->m_Means.size(); b++)
{
std::size_t bands;
fread(&(bands), sizeof(bands), 1, nodeStream);
node->m_Means.assign(bands, 0);
node->m_SquareMeans.assign(bands, 0);
node->m_SpectralSum.assign(bands, 0);
node->m_Std.assign(bands, 0);
for(unsigned int b = 0; b < bands; b++)
{
fread(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
fread(&(node->m_SquareMeans[b]), sizeof(node->m_SquareMeans[b]), 1, nodeStream);
fread(&(node->m_SpectralSum[b]), sizeof(node->m_SpectralSum[b]), 1, nodeStream);
fread(&(node->m_Std[b]), sizeof(node->m_Std[b]), 1, nodeStream);
}
fwrite(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
fwrite(&(node->m_SquareMeans[b]), sizeof(node->m_SquareMeans[b]), 1, nodeStream);
fwrite(&(node->m_SpectralSum[b]), sizeof(node->m_SpectralSum[b]), 1, nodeStream);
fwrite(&(node->m_Std[b]), sizeof(node->m_Std[b]), 1, nodeStream);
}
}
template<class TImage>
long long unsigned int
BaatzSegmenter<TImage>::GetNodeMemory(NodePointerType &node)
template<class TImage>
void
BaatzSegmenter<TImage>::ReadSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands;
fread(&(bands), sizeof(bands), 1, nodeStream);
node->m_Means.assign(bands, 0);
node->m_SquareMeans.assign(bands, 0);
node->m_SpectralSum.assign(bands, 0);
node->m_Std.assign(bands, 0);
for(unsigned int b = 0; b < bands; b++)
{
fread(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
fread(&(node->m_SquareMeans[b]), sizeof(node->m_SquareMeans[b]), 1, nodeStream);
fread(&(node->m_SpectralSum[b]), sizeof(node->m_SpectralSum[b]), 1, nodeStream);
fread(&(node->m_Std[b]), sizeof(node->m_Std[b]), 1, nodeStream);
}
}
unsigned int nBands = node->m_Means.size(); //this->m_InputImage->GetNumberOfComponentsPerPixel();
template<class TImage>
long long unsigned int
BaatzSegmenter<TImage>::GetNodeMemory(NodePointerType &node)
{
long long unsigned int memory = 0;
memory += sizeof(NodePointerType); // size of the node pointer
memory += sizeof(NodeType); // size of the node (actually, size of the base node)
memory += 4 * nBands * sizeof(float); // size of the 4 attributes, multiplied by the nb. of bands
memory += node->m_Edges.size() * sizeof(EdgeType); // size of the edges
return memory;
}
unsigned int nBands = node->m_Means.size(); //this->m_InputImage->GetNumberOfComponentsPerPixel();
long long unsigned int memory = 0;
memory += sizeof(NodePointerType); // size of the node pointer
memory += sizeof(NodeType); // size of the node (actually, size of the base node)
memory += 4 * nBands * sizeof(float); // size of the 4 attributes, multiplied by the nb. of bands
memory += node->m_Edges.size() * sizeof(EdgeType); // size of the edges
return memory;
}
} // end of namespace lsrm
#endif
...
...
include/lsgrmController.txx
View file @
aa288e4d
...
...
@@ -108,10 +108,6 @@ void Controller<TSegmenter>::RunSegmentation()
{
numberOfIterationsRemaining -= numberOfIterationsForPartialSegmentations;
}
else
{
isFusion = false;
}
#ifdef OTB_USE_MPI
// Gathering useful variables
...
...
@@ -152,11 +148,21 @@ void Controller<TSegmenter>::RunSegmentation()
itkExceptionMacro(<< "No more possible fusions, but can not store the output graph");
}
}
else // tiling_mode is none
else
if (m_TilingMode == LSGRM_TILING_NONE)
// tiling_mode is none
{
// todo use classic grm
// Use classic grm
TSegmenter segmenter;
segmenter.SetParam(m_SpecificParameters);
segmenter.SetThreshold(m_Threshold);
segmenter.SetDoFastSegmentation(true);
segmenter.SetNumberOfIterations(m_NumberOfIterations);
segmenter.SetInput(m_InputImage);
segmenter.Update();
}
else
{
itkExceptionMacro(<<"Unknow tiling mode!");
}
}
...
...
include/lsgrmFullLambdaScheduleSegmenter.txx
View file @
aa288e4d
...
...
@@ -6,47 +6,47 @@
namespace lsgrm
{
template<class TImage>
void
FullLambdaScheduleSegmenter<TImage>::WriteSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands = node->m_Means.size();
fwrite(&(bands), sizeof(bands), 1, nodeStream);
for(unsigned int b = 0; b < node->m_Means.size(); b++)
{
fwrite(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
}
template<class TImage>
void
FullLambdaScheduleSegmenter<TImage>::ReadSpecificAttributes(NodePointerType node, FILE * nodeStream)
template<class TImage>
void
FullLambdaScheduleSegmenter<TImage>::WriteSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands = node->m_Means.size();
fwrite(&(bands), sizeof(bands), 1, nodeStream);
for(unsigned int b = 0; b < node->m_Means.size(); b++)
{
std::size_t bands;
fread(&(bands), sizeof(bands), 1, nodeStream);
node->m_Means.assign(bands, 0);
for(unsigned int b = 0; b < bands; b++)
{
fread(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
fwrite(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
}
template<class TImage>
void
FullLambdaScheduleSegmenter<TImage>::ReadSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands;
fread(&(bands), sizeof(bands), 1, nodeStream);
node->m_Means.assign(bands, 0);
template<class TImage>
long long unsigned int
FullLambdaScheduleSegmenter<TImage>::GetNodeMemory(NodePointerType &node)
for(unsigned int b = 0; b < bands; b++)
{
fread(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
}
template<class TImage>
long long unsigned int
FullLambdaScheduleSegmenter<TImage>::GetNodeMemory(NodePointerType &node)
{
unsigned int nBands = node->m_Means.size(); //this->m_InputImage->GetNumberOfComponentsPerPixel();
unsigned int nBands = node->m_Means.size(); //this->m_InputImage->GetNumberOfComponentsPerPixel();
long long unsigned int memory = 0;
memory += sizeof(NodePointerType); // size of the node pointer
memory += sizeof(NodeType); // size of the node (actually, size of the base node)
memory += 1 * nBands * sizeof(float); // size of the 1 attribute, multiplied by the nb. of bands
memory += node->m_Edges.size() * sizeof(EdgeType); // size of the edges
return memory;
}
long long unsigned int memory = 0;
memory += sizeof(NodePointerType); // size of the node pointer
memory += sizeof(NodeType); // size of the node (actually, size of the base node)
memory += 1 * nBands * sizeof(float); // size of the 1 attribute, multiplied by the nb. of bands
memory += node->m_Edges.size() * sizeof(EdgeType); // size of the edges
return memory;
}
} // end of namespace lsrm
#endif
...
...
include/lsgrmGraphOperations.txx
View file @
aa288e4d
...
...
@@ -661,14 +661,14 @@ long long unsigned int RunFirstPartialSegmentation(
// and write them to the stability margin
std::cout << "\tComputing stability margin..." << std::endl;
{
std::unordered_map<typename TSegmenter::NodePointerType, unsigned int> borderNodeMap;
std::unordered_map<typename TSegmenter::NodePointerType, unsigned int> borderNodeMap;
DetectBorderNodes<TSegmenter>(segmenter.m_Graph, currentTile,
borderNodeMap, imageWidth, imageHeight);
DetectBorderNodes<TSegmenter>(segmenter.m_Graph, currentTile,
borderNodeMap, imageWidth, imageHeight);
ExtractStabilityMargin<TSegmenter>(borderNodeMap, numberOfNeighborLayers);
ExtractStabilityMargin<TSegmenter>(borderNodeMap, numberOfNeighborLayers);
WriteStabilityMargin<TSegmenter>(borderNodeMap, currentTile.nodeMarginFileName, currentTile.edgeMarginFileName);
WriteStabilityMargin<TSegmenter>(borderNodeMap, currentTile.nodeMarginFileName, currentTile.edgeMarginFileName);
}
}
} // for each col
...
...
include/lsgrmGraphToOtbImage.h
View file @
aa288e4d
...
...
@@ -14,26 +14,26 @@
namespace
lsgrm
{
template
<
class
TGraph
>
class
GraphToOtbImage
{
public:
/* Some convenient typedefs */
typedef
TGraph
GraphType
;
typedef
typename
GraphType
::
NodeType
NodeType
;
typedef
std
::
vector
<
std
::
shared_ptr
<
NodeType
>
>
NodeList
;
typedef
typename
NodeList
::
const_iterator
NodeConstIterator
;
typedef
unsigned
int
LabelPixelType
;
typedef
otb
::
Image
<
LabelPixelType
,
2
>
LabelImageType
;
using
ContourOperator
=
lp
::
ContourOperations
;
template
<
class
TGraph
>
class
GraphToOtbImage
{
public:
/* Some convenient typedefs */
typedef
TGraph
GraphType
;
typedef
typename
GraphType
::
NodeType
NodeType
;
typedef
std
::
vector
<
std
::
shared_ptr
<
NodeType
>
>
NodeList
;
typedef
typename
NodeList
::
const_iterator
NodeConstIterator
;
typedef
unsigned
int
LabelPixelType
;
typedef
otb
::
Image
<
LabelPixelType
,
2
>
LabelImageType
;
using
ContourOperator
=
lp
::
ContourOperations
;
LabelImageType
::
Pointer
GetLabelImage
(
const
GraphType
&
graph
,
const
unsigned
int
width
,
const
unsigned
int
height
);
};
LabelImageType
::
Pointer
GetLabelImage
(
const
GraphType
&
graph
,
const
unsigned
int
width
,
const
unsigned
int
height
);
};
}
// end of namespace lsrm
#include "lsgrmGraphToOtbImage.txx"
#endif
include/lsgrmGraphToOtbImage.txx
View file @
aa288e4d
...
...
@@ -6,70 +6,70 @@
namespace lsgrm
{
template<class TGraph>
typename GraphToOtbImage<TGraph>::LabelImageType::Pointer
GraphToOtbImage<TGraph>::GetLabelImage(const GraphType& graph,
const unsigned int width,
const unsigned int height)
{
LabelImageType::IndexType labelImageRegionStart;
LabelImageType::SizeType labelImageRegionSize;
LabelImageType::RegionType labelImageRegion;
template<class TGraph>
typename GraphToOtbImage<TGraph>::LabelImageType::Pointer
GraphToOtbImage<TGraph>::GetLabelImage(const GraphType& graph,
const unsigned int width,
const unsigned int height)
{
LabelImageType::IndexType labelImageRegionStart;
LabelImageType::SizeType labelImageRegionSize;
LabelImageType::RegionType labelImageRegion;
labelImageRegionStart[0] = 0; labelImageRegionStart[1] = 0;
labelImageRegionSize[0] = width; labelImageRegionSize[1] = height;
labelImageRegion.SetIndex(labelImageRegionStart);
labelImageRegion.SetSize(labelImageRegionSize);
labelImageRegionStart[0] = 0; labelImageRegionStart[1] = 0;
labelImageRegionSize[0] = width; labelImageRegionSize[1] = height;
labelImageRegion.SetIndex(labelImageRegionStart);
labelImageRegion.SetSize(labelImageRegionSize);
LabelImageType::Pointer label_img = LabelImageType::New();
label_img->SetRegions(labelImageRegion);
label_img->Allocate();
LabelImageType::Pointer label_img = LabelImageType::New();
label_img->SetRegions(labelImageRegion);
label_img->Allocate();
using LabelImageIterator = itk::ImageRegionIterator<LabelImageType>;
LabelImageIterator it(label_img, label_img->GetLargestPossibleRegion());
for(it.GoToBegin();!it.IsAtEnd(); ++it)
it.Set(0);
// Start at 1 (value 0 can be used for invalid pixels)
LabelImageType::InternalPixelType label = 1;
for(auto& region : graph.m_Nodes)
{
lp::CellLists borderPixels;
ContourOperator::GenerateBorderCells(borderPixels, region->m_Contour, region->m_Id, width);
for (auto& pix: borderPixels)
{
labelImageRegionStart[0] = pix % width;
labelImageRegionStart[1] = pix / width;
label_img->SetPixel(labelImageRegionStart, label);
}
++label;
}
using LabelImageIterator = itk::ImageRegionIterator<LabelImageType>;
LabelImageIterator it(label_img, label_img->GetLargestPossibleRegion());
for(it.GoToBegin();!it.IsAtEnd(); ++it)
it.Set(0);
// Sort labels in their appearance order from left->right to top->bottom
const LabelImageType::InternalPixelType noDataLabel = 0;
vnl_vector<LabelImageType::InternalPixelType> lut(label,noDataLabel);
label=1;
for(it.GoToBegin();!it.IsAtEnd(); ++it)
{
unsigned int inputLabel = it.Get();
if (lut[ inputLabel ] == noDataLabel)
{
lut[ inputLabel ] = label;
label++;
}
}
for(it.GoToBegin();!it.IsAtEnd(); ++it)
it.Set(lut[it.Get()]);
// Start at 1 (value 0 can be used for invalid pixels)
LabelImageType::InternalPixelType label = 1;
for(auto& region : graph.m_Nodes)
{
lp::CellLists borderPixels;
ContourOperator::GenerateBorderCells(borderPixels, region->m_Contour, region->m_Id, width);
for (auto& pix: borderPixels)
{
labelImageRegionStart[0] = pix % width;
labelImageRegionStart[1] = pix / width;
label_img->SetPixel(labelImageRegionStart, label);
}
++label;
}
// Sort labels in their appearance order from left->right to top->bottom
const LabelImageType::InternalPixelType noDataLabel = 0;
vnl_vector<LabelImageType::InternalPixelType> lut(label,noDataLabel);
label=1;
for(it.GoToBegin();!it.IsAtEnd(); ++it)
{
unsigned int inputLabel = it.Get();
if (lut[ inputLabel ] == noDataLabel)
{
lut[ inputLabel ] = label;
label++;
}
}
for(it.GoToBegin();!it.IsAtEnd(); ++it)
it.Set(lut[it.Get()]);
// Fill holes
typedef itk::GrayscaleFillholeImageFilter<LabelImageType,LabelImageType> FillholeFilterType;
FillholeFilterType::Pointer fillFilter = FillholeFilterType::New();
fillFilter->SetInput(label_img);
fillFilter->Update();
return fillFilter->GetOutput();
}
// Fill holes
typedef itk::GrayscaleFillholeImageFilter<LabelImageType,LabelImageType> FillholeFilterType;
FillholeFilterType::Pointer fillFilter = FillholeFilterType::New();
fillFilter->SetInput(label_img);
fillFilter->Update();
return fillFilter->GetOutput();
}
} // end of namespace lsrm
#endif
include/lsgrmSplitter.txx
View file @
aa288e4d
...
...
@@ -4,10 +4,10 @@ namespace lsgrm
{
enum RelativePosition{
POS_TOP,
POS_RIGHT,
POS_BOTTOM,
POS_LEFT
POS_TOP,
POS_RIGHT,
POS_BOTTOM,
POS_LEFT
};
enum NeighborhoodRelativePosition{
...
...
@@ -29,7 +29,7 @@ std::vector<ProcessingTile> SplitOTBImage(TInputImage * imagePtr, // input image
unsigned int &nbTilesX,
unsigned int &nbTilesY,
std::string temporaryFilesPrefix)
{
{
std::vector<ProcessingTile> tiles;
...
...
@@ -173,5 +173,5 @@ std::vector<ProcessingTile> SplitOTBImage(TInputImage * imagePtr, // input image
} // for(unsigned int row = 0; row < nbTilesY; ++row)
return tiles;
}
}
} // end of namespace lsgrm
include/lsgrmSpringSegmenter.txx
View file @
aa288e4d
...
...
@@ -6,47 +6,47 @@
namespace lsgrm
{
template<class TImage>
void
SpringSegmenter<TImage>::WriteSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands = node->m_Means.size();
fwrite(&(bands), sizeof(bands), 1, nodeStream);
for(unsigned int b = 0; b < node->m_Means.size(); b++)
{
fwrite(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
}
template<class TImage>
void
SpringSegmenter<TImage>::ReadSpecificAttributes(NodePointerType node, FILE * nodeStream)
template<class TImage>
void
SpringSegmenter<TImage>::WriteSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands = node->m_Means.size();
fwrite(&(bands), sizeof(bands), 1, nodeStream);
for(unsigned int b = 0; b < node->m_Means.size(); b++)
{
std::size_t bands;
fread(&(bands), sizeof(bands), 1, nodeStream);
node->m_Means.assign(bands, 0);
for(unsigned int b = 0; b < bands; b++)
{
fread(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
fwrite(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
}
template<class TImage>
void
SpringSegmenter<TImage>::ReadSpecificAttributes(NodePointerType node, FILE * nodeStream)
{
std::size_t bands;
fread(&(bands), sizeof(bands), 1, nodeStream);
node->m_Means.assign(bands, 0);
template<class TImage>
long long unsigned int
SpringSegmenter<TImage>::GetNodeMemory(NodePointerType &node)
for(unsigned int b = 0; b < bands; b++)
{
fread(&(node->m_Means[b]), sizeof(node->m_Means[b]), 1, nodeStream);
}
}
template<class TImage>
long long unsigned int
SpringSegmenter<TImage>::GetNodeMemory(NodePointerType &node)
{
unsigned int nBands = node->m_Means.size(); //this->m_InputImage->GetNumberOfComponentsPerPixel();
unsigned int nBands = node->m_Means.size(); //this->m_InputImage->GetNumberOfComponentsPerPixel();
long long unsigned int memory = 0;
memory += sizeof(NodePointerType); // size of the node pointer
memory += sizeof(NodeType); // size of the node (actually, size of the base node)
memory += 1 * nBands * sizeof(float); // size of the 1 attribute, multiplied by the nb. of bands
memory += node->m_Edges.size() * sizeof(EdgeType); // size of the edges
return memory;
}
long long unsigned int memory = 0;
memory += sizeof(NodePointerType); // size of the node pointer
memory += sizeof(NodeType); // size of the node (actually, size of the base node)
memory += 1 * nBands * sizeof(float); // size of the 1 attribute, multiplied by the nb. of bands
memory += node->m_Edges.size() * sizeof(EdgeType); // size of the edges
return memory;
}
} // end of namespace lsrm
#endif
...
...
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