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
GRM
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
GRM
Commits
45a3be1c
Commit
45a3be1c
authored
Mar 24, 2017
by
remi cresson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
REFAC: refactorisation segmenter
parent
273d9b6a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
87 deletions
+87
-87
include/grmBaatzSegmenter.h
include/grmBaatzSegmenter.h
+3
-2
include/grmBaatzSegmenter.txx
include/grmBaatzSegmenter.txx
+18
-42
include/grmFullLambdaScheduleSegmenter.h
include/grmFullLambdaScheduleSegmenter.h
+4
-2
include/grmFullLambdaScheduleSegmenter.txx
include/grmFullLambdaScheduleSegmenter.txx
+10
-20
include/grmSegmenter.h
include/grmSegmenter.h
+45
-4
include/grmSpringSegmenter.h
include/grmSpringSegmenter.h
+3
-1
include/grmSpringSegmenter.txx
include/grmSpringSegmenter.txx
+4
-16
No files found.
include/grmBaatzSegmenter.h
View file @
45a3be1c
...
@@ -43,6 +43,7 @@ namespace grm
...
@@ -43,6 +43,7 @@ namespace grm
/* Some convenient typedefs */
/* Some convenient typedefs */
typedef
Segmenter
<
TImage
,
BaatzNode
,
BaatzParam
>
Superclass
;
typedef
Segmenter
<
TImage
,
BaatzNode
,
BaatzParam
>
Superclass
;
typedef
TImage
ImageType
;
typedef
TImage
ImageType
;
typedef
typename
ImageType
::
PixelType
PixelType
;
typedef
BaatzParam
ParameterType
;
typedef
BaatzParam
ParameterType
;
typedef
typename
Superclass
::
GraphType
GraphType
;
typedef
typename
Superclass
::
GraphType
GraphType
;
typedef
BaatzNode
NodeType
;
typedef
BaatzNode
NodeType
;
...
@@ -53,8 +54,8 @@ namespace grm
...
@@ -53,8 +54,8 @@ namespace grm
float
ComputeMergingCost
(
NodePointerType
n1
,
NodePointerType
n2
);
float
ComputeMergingCost
(
NodePointerType
n1
,
NodePointerType
n2
);
void
UpdateSpecificAttributes
(
NodePointerType
n1
,
NodePointerType
n2
);
void
UpdateSpecificAttributes
(
NodePointerType
n1
,
NodePointerType
n2
);
void
InitFromImage
(
);
void
UpdateSpecificAttributes
(
NodePointerType
n
,
PixelType
p
);
};
};
}
// end of namespace grm
}
// end of namespace grm
#include "grmBaatzSegmenter.txx"
#include "grmBaatzSegmenter.txx"
#endif
#endif
\ No newline at end of file
include/grmBaatzSegmenter.txx
View file @
45a3be1c
...
@@ -17,52 +17,28 @@
...
@@ -17,52 +17,28 @@
=========================================================================*/
=========================================================================*/
#ifndef GRM_BAATZ_SEGMENTER_TXX
#ifndef GRM_BAATZ_SEGMENTER_TXX
#define GRM_BAATZ_SEGMENTER_TXX
#define GRM_BAATZ_SEGMENTER_TXX
#include <otbImageFileReader.h>
#include <itkImageRegionIterator.h>
#include "grmBaatzSegmenter.h"
#include "grmBaatzSegmenter.h"
#include "otbNoDataHelper.h"
namespace grm
namespace grm
{
{
template<class TImage>
template<class TImage>
void
void
BaatzSegmenter<TImage>::InitFromImage()
BaatzSegmenter<TImage>::UpdateSpecificAttributes(NodePointerType n, PixelType p)
{
{
typedef itk::ImageRegionIterator<TImage> ImageIterator;
n->m_Means.reserve(p.GetSize());
this->m_ImageWidth = this->m_InputImage->GetLargestPossibleRegion().GetSize()[0];
n->m_SquareMeans.reserve(p.GetSize());
this->m_ImageHeight =this->m_InputImage->GetLargestPossibleRegion().GetSize()[1];
n->m_SpectralSum.reserve(p.GetSize());
this->m_NumberOfComponentsPerPixel = this->m_InputImage->GetNumberOfComponentsPerPixel();
n->m_Std.assign(p.GetSize(), 0.0f);
std::vector<bool> noDataFlags;
for(std::size_t b = 0; b < p.GetSize(); ++b)
std::vector<double> noDataValues;
{
bool noDataPresent = otb::ReadNoDataFlags(this->m_InputImage->GetMetaDataDictionary(),noDataFlags,noDataValues);
n->m_Means.push_back(p[b]);
n->m_SquareMeans.push_back((p[b])*(p[b]));
std::size_t idx = 0;
n->m_SpectralSum.push_back(p[b]);
ImageIterator it(this->m_InputImage, this->m_InputImage->GetLargestPossibleRegion());
}
for(it.GoToBegin(); !it.IsAtEnd(); ++it)
}
{
if (noDataPresent && otb::IsNoData<double>(it.Get(),noDataFlags,noDataValues)) {
this->m_Graph.m_Nodes[idx]->m_Expired = true;
} else {
this->m_Graph.m_Nodes[idx]->m_Means.reserve(this->m_NumberOfComponentsPerPixel);
this->m_Graph.m_Nodes[idx]->m_SquareMeans.reserve(this->m_NumberOfComponentsPerPixel);
this->m_Graph.m_Nodes[idx]->m_SpectralSum.reserve(this->m_NumberOfComponentsPerPixel);
this->m_Graph.m_Nodes[idx]->m_Std.assign(this->m_NumberOfComponentsPerPixel, 0.0f);
for(std::size_t b = 0; b < this->m_NumberOfComponentsPerPixel; ++b)
{
this->m_Graph.m_Nodes[idx]->m_Means.push_back(it.Get()[b]);
this->m_Graph.m_Nodes[idx]->m_SquareMeans.push_back((it.Get()[b])*(it.Get()[b]));
this->m_Graph.m_Nodes[idx]->m_SpectralSum.push_back(it.Get()[b]);
}
}
++idx;
}
}
template<class TImage>
template<class TImage>
float
float
...
@@ -128,4 +104,4 @@ namespace grm
...
@@ -128,4 +104,4 @@ namespace grm
}
}
} // end of namespace grm
} // end of namespace grm
#endif
#endif
\ No newline at end of file
include/grmFullLambdaScheduleSegmenter.h
View file @
45a3be1c
...
@@ -35,6 +35,8 @@ namespace grm
...
@@ -35,6 +35,8 @@ namespace grm
/* Some convenient typedefs */
/* Some convenient typedefs */
typedef
Segmenter
<
TImage
,
FLSNode
,
FLSParam
>
Superclass
;
typedef
Segmenter
<
TImage
,
FLSNode
,
FLSParam
>
Superclass
;
typedef
TImage
ImageType
;
typedef
TImage
ImageType
;
typedef
typename
ImageType
::
PixelType
PixelType
;
typedef
typename
Superclass
::
GraphType
GraphType
;
typedef
typename
Superclass
::
GraphType
GraphType
;
typedef
typename
Superclass
::
NodePointerType
NodePointerType
;
typedef
typename
Superclass
::
NodePointerType
NodePointerType
;
typedef
typename
Superclass
::
GraphOperatorType
GraphOperatorType
;
typedef
typename
Superclass
::
GraphOperatorType
GraphOperatorType
;
...
@@ -42,8 +44,8 @@ namespace grm
...
@@ -42,8 +44,8 @@ namespace grm
float
ComputeMergingCost
(
NodePointerType
n1
,
NodePointerType
n2
);
float
ComputeMergingCost
(
NodePointerType
n1
,
NodePointerType
n2
);
void
UpdateSpecificAttributes
(
NodePointerType
n1
,
NodePointerType
n2
);
void
UpdateSpecificAttributes
(
NodePointerType
n1
,
NodePointerType
n2
);
void
InitFromImage
(
);
void
UpdateSpecificAttributes
(
NodePointerType
n
,
PixelType
p
);
};
};
}
// end of namespace grm
}
// end of namespace grm
#include "grmFullLambdaScheduleSegmenter.txx"
#include "grmFullLambdaScheduleSegmenter.txx"
#endif
#endif
\ No newline at end of file
include/grmFullLambdaScheduleSegmenter.txx
View file @
45a3be1c
...
@@ -22,29 +22,19 @@
...
@@ -22,29 +22,19 @@
namespace grm
namespace grm
{
{
template<class TImage>
template<class TImage>
void
void
FullLambdaScheduleSegmenter<TImage>::InitFromImage()
FullLambdaScheduleSegmenter<TImage>::UpdateSpecificAttributes(NodePointerType n, PixelType p)
{
{
typedef itk::ImageRegionIterator<TImage> ImageIterator;
this->m_ImageWidth = this->m_InputImage->GetLargestPossibleRegion().GetSize()[0];
n->m_Means.reserve(p.GetSize());
this->m_ImageHeight =this->m_InputImage->GetLargestPossibleRegion().GetSize()[1];
this->m_NumberOfComponentsPerPixel = this->m_InputImage->GetNumberOfComponentsPerPixel();
std::size_t idx = 0;
for(std::size_t b = 0; b < p.GetSize(); ++b)
ImageIterator it(this->m_InputImage, this->m_InputImage->GetLargestPossibleRegion());
{
for(it.GoToBegin(); !it.IsAtEnd(); ++it)
n->m_Means.push_back(p[b]);
{
}
this->m_Graph.m_Nodes[idx]->m_Means.reserve(this->m_NumberOfComponentsPerPixel);
for(std::size_t b = 0; b < this->m_NumberOfComponentsPerPixel; ++b)
}
{
this->m_Graph.m_Nodes[idx]->m_Means.push_back(it.Get()[b]);
}
++idx;
}
}
template<class TImage>
template<class TImage>
float
float
...
...
include/grmSegmenter.h
View file @
45a3be1c
...
@@ -20,6 +20,9 @@
...
@@ -20,6 +20,9 @@
#include "grmMacroGenerator.h"
#include "grmMacroGenerator.h"
#include "grmGraphOperations.h"
#include "grmGraphOperations.h"
#include "grmGraphToOtbImage.h"
#include "grmGraphToOtbImage.h"
#include <otbImageFileReader.h>
#include <itkImageRegionIterator.h>
#include "otbNoDataHelper.h"
namespace
grm
namespace
grm
{
{
...
@@ -32,6 +35,7 @@ namespace grm
...
@@ -32,6 +35,7 @@ namespace grm
typedef
Segmenter
<
TImage
,
TNode
,
TParam
>
Self
;
typedef
Segmenter
<
TImage
,
TNode
,
TParam
>
Self
;
typedef
TImage
ImageType
;
typedef
TImage
ImageType
;
typedef
typename
ImageType
::
PixelType
PixelType
;
typedef
TNode
NodeType
;
typedef
TNode
NodeType
;
typedef
TParam
ParamType
;
typedef
TParam
ParamType
;
typedef
Graph
<
NodeType
>
GraphType
;
typedef
Graph
<
NodeType
>
GraphType
;
...
@@ -97,14 +101,51 @@ namespace grm
...
@@ -97,14 +101,51 @@ namespace grm
*/
*/
virtual
void
UpdateSpecificAttributes
(
NodePointerType
n1
,
NodePointerType
n2
)
=
0
;
virtual
void
UpdateSpecificAttributes
(
NodePointerType
n1
,
NodePointerType
n2
)
=
0
;
/*
* Given 1 smart adjacent node pointer (boost::shared_ptr), this
* method updates the customized attributes of the node according
* to the given pixel.
*
* @params
* NodePointerType n : Smart pointer to node
* PixelType p: pixel used for attributes computation
*
*/
virtual
void
UpdateSpecificAttributes
(
NodePointerType
n
,
PixelType
p
)
=
0
;
/*
/*
* Given the input image, this method initializes the
* Given the input image, this method initializes the
* internal and specific attributes of the graph.
* internal and specific attributes of the graph.
*
*
* @params
* const std::string& inputFileName : input image path
*/
*/
virtual
void
InitFromImage
()
=
0
;
virtual
void
InitFromImage
()
{
typedef
itk
::
ImageRegionIterator
<
ImageType
>
ImageIterator
;
this
->
m_ImageWidth
=
this
->
m_InputImage
->
GetLargestPossibleRegion
().
GetSize
()[
0
];
this
->
m_ImageHeight
=
this
->
m_InputImage
->
GetLargestPossibleRegion
().
GetSize
()[
1
];
this
->
m_NumberOfComponentsPerPixel
=
this
->
m_InputImage
->
GetNumberOfComponentsPerPixel
();
std
::
vector
<
bool
>
noDataFlags
;
std
::
vector
<
double
>
noDataValues
;
bool
noDataPresent
=
otb
::
ReadNoDataFlags
(
this
->
m_InputImage
->
GetMetaDataDictionary
(),
noDataFlags
,
noDataValues
);
std
::
size_t
idx
=
0
;
ImageIterator
it
(
this
->
m_InputImage
,
this
->
m_InputImage
->
GetLargestPossibleRegion
());
for
(
it
.
GoToBegin
();
!
it
.
IsAtEnd
();
++
it
)
{
if
(
noDataPresent
&&
otb
::
IsNoData
<
double
>
(
it
.
Get
(),
noDataFlags
,
noDataValues
))
{
this
->
m_Graph
.
m_Nodes
[
idx
]
->
m_Expired
=
true
;
}
else
{
UpdateSpecificAttributes
(
this
->
m_Graph
.
m_Nodes
[
idx
],
it
.
Get
());
}
++
idx
;
}
}
/* Return the label image */
/* Return the label image */
inline
typename
LabelImageType
::
Pointer
GetLabeledClusteredOutput
()
inline
typename
LabelImageType
::
Pointer
GetLabeledClusteredOutput
()
...
@@ -170,4 +211,4 @@ namespace grm
...
@@ -170,4 +211,4 @@ namespace grm
};
};
}
// end of namespace grm
}
// end of namespace grm
#endif
#endif
\ No newline at end of file
include/grmSpringSegmenter.h
View file @
45a3be1c
...
@@ -35,6 +35,8 @@ namespace grm
...
@@ -35,6 +35,8 @@ namespace grm
/* Some convenient typedefs */
/* Some convenient typedefs */
typedef
Segmenter
<
TImage
,
SpringNode
,
SpringParam
>
Superclass
;
typedef
Segmenter
<
TImage
,
SpringNode
,
SpringParam
>
Superclass
;
typedef
TImage
ImageType
;
typedef
TImage
ImageType
;
typedef
typename
ImageType
::
PixelType
PixelType
;
typedef
typename
Superclass
::
GraphType
GraphType
;
typedef
typename
Superclass
::
GraphType
GraphType
;
typedef
typename
Superclass
::
NodePointerType
NodePointerType
;
typedef
typename
Superclass
::
NodePointerType
NodePointerType
;
typedef
typename
Superclass
::
GraphOperatorType
GraphOperatorType
;
typedef
typename
Superclass
::
GraphOperatorType
GraphOperatorType
;
...
@@ -42,7 +44,7 @@ namespace grm
...
@@ -42,7 +44,7 @@ namespace grm
float
ComputeMergingCost
(
NodePointerType
n1
,
NodePointerType
n2
);
float
ComputeMergingCost
(
NodePointerType
n1
,
NodePointerType
n2
);
void
UpdateSpecificAttributes
(
NodePointerType
n1
,
NodePointerType
n2
);
void
UpdateSpecificAttributes
(
NodePointerType
n1
,
NodePointerType
n2
);
void
InitFromImage
(
);
void
UpdateSpecificAttributes
(
NodePointerType
n
,
PixelType
p
);
};
};
}
// end of namespace grm
}
// end of namespace grm
#include "grmSpringSegmenter.txx"
#include "grmSpringSegmenter.txx"
...
...
include/grmSpringSegmenter.txx
View file @
45a3be1c
...
@@ -26,26 +26,14 @@ namespace grm
...
@@ -26,26 +26,14 @@ namespace grm
template<class TImage>
template<class TImage>
void
void
SpringSegmenter<TImage>::
InitFromImage(
)
SpringSegmenter<TImage>::
UpdateSpecificAttributes(NodePointerType n, PixelType p
)
{
{
typedef itk::ImageRegionIterator<TImage> ImageIterator
;
n->m_Means.reserve(p.GetSize())
;
this->m_ImageWidth = this->m_InputImage->GetLargestPossibleRegion().GetSize()[0];
for(std::size_t b = 0; b < p.GetSize(); ++b)
this->m_ImageHeight =this->m_InputImage->GetLargestPossibleRegion().GetSize()[1];
this->m_NumberOfComponentsPerPixel = this->m_InputImage->GetNumberOfComponentsPerPixel();
std::size_t idx = 0;
ImageIterator it(this->m_InputImage, this->m_InputImage->GetLargestPossibleRegion());
for(it.GoToBegin(); !it.IsAtEnd(); ++it)
{
this->m_Graph.m_Nodes[idx]->m_Means.reserve(this->m_NumberOfComponentsPerPixel);
for(std::size_t b = 0; b < this->m_NumberOfComponentsPerPixel; ++b)
{
{
this->m_Graph.m_Nodes[idx]->m_Means.push_back(it.Get()
[b]);
n->m_Means.push_back(p
[b]);
}
}
++idx;
}
}
}
template<class TImage>
template<class TImage>
...
...
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