Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Youssefi
otb
Commits
8c71a0e7
Commit
8c71a0e7
authored
13 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
STYLE: and fix test for gamma
parent
99100bc7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Markov/otbMRFEnergyFisherClassification.h
+53
-50
53 additions, 50 deletions
Code/Markov/otbMRFEnergyFisherClassification.h
Testing/Code/Common/otbGammaTest.cxx
+7
-4
7 additions, 4 deletions
Testing/Code/Common/otbGammaTest.cxx
with
60 additions
and
54 deletions
Code/Markov/otbMRFEnergyFisherClassification.h
+
53
−
50
View file @
8c71a0e7
...
...
@@ -27,62 +27,65 @@
namespace
otb
{
/*
\* class MRFEnergyFisherClassification
\* This is the implementation of the Fisher model for Markov classification
\* to be used for the fidelity (likelihood) term for the classification.
\*
\* This class is meant to be used in the MRF framework with the otb:: MarkovRandomFieldFilter
/**
* \class MRFEnergyFisherClassification
* \brief Fisher model for Markov classification
*
* This is the implementation of the Fisher model for Markov classification
* to be used for the fidelity (likelihood) term for the classification.
*
* This class is meant to be used in the MRF framework with the
* otb::MarkovRandomFieldFilter
*
*/
template
<
class
TInput1
,
class
TInput2
>
class
ITK_EXPORT
MRFEnergyFisherClassification
:
public
MRFEnergy
<
TInput1
,
TInput2
>
class
ITK_EXPORT
MRFEnergyFisherClassification
:
public
MRFEnergy
<
TInput1
,
TInput2
>
{
public:
typedef
MRFEnergyFisherClassification
Self
;
typedef
MRFEnergy
<
TInput1
,
TInput2
>
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
typedef
TInput1
InputImageType
;
typedef
TInput2
LabelledImageType
;
typedef
typename
InputImageType
::
PixelType
InputImagePixelType
;
typedef
typename
LabelledImageType
::
PixelType
LabelledImagePixelType
;
typedef
itk
::
Array
<
double
>
ParametersType
;
itkNewMacro
(
Self
);
itkTypeMacro
(
MRFEnergyFisherClassification
,
MRFEnergy
);
Gamma
g
;
void
SetNumberOfParameters
(
const
unsigned
int
nParameters
)
{
Superclass
::
SetNumberOfParameters
(
nParameters
);
this
->
m_Parameters
.
SetSize
(
nParameters
);
this
->
Modified
();
}
double
GetSingleValue
(
const
InputImagePixelType
&
value1
,
const
LabelledImagePixelType
&
value2
)
{
if
((
unsigned
int
)
value2
>=
this
->
GetNumberOfParameters
()
/
3
)
{
itkExceptionMacro
(
<<
"Number of parameters does not correspond to number of classes"
);
}
double
val1
=
static_cast
<
double
>
(
value1
);
double
mu
=
this
->
m_Parameters
[
3
*
static_cast
<
double
>
(
value2
)];
double
l
=
this
->
m_Parameters
[
3
*
static_cast
<
double
>
(
value2
)
+
1
];
double
m
=
this
->
m_Parameters
[
3
*
static_cast
<
double
>
(
value2
)
+
2
];
double
result
=
-
vcl_log
((
g
.
gamma
(
l
+
m
)
/
(
g
.
gamma
(
l
)
*
g
.
gamma
(
m
)))
*
(
2
/
(
mu
))
*
(
vcl_sqrt
(
l
/
m
))
*
((
pow
((
vcl_sqrt
(
l
/
m
)
*
(
val1
/
mu
)),
((
2
*
l
)
-
1
)))
/
(
pow
(
1
+
(
vcl_sqrt
(
l
/
m
)
*
(
val1
/
mu
)
*
vcl_sqrt
(
l
/
m
)
*
(
val1
/
mu
)),
(
l
+
m
)))));
return
static_cast
<
double
>
(
result
);
}
typedef
MRFEnergyFisherClassification
Self
;
typedef
MRFEnergy
<
TInput1
,
TInput2
>
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
typedef
TInput1
InputImageType
;
typedef
TInput2
LabelledImageType
;
typedef
typename
InputImageType
::
PixelType
InputImagePixelType
;
typedef
typename
LabelledImageType
::
PixelType
LabelledImagePixelType
;
typedef
itk
::
Array
<
double
>
ParametersType
;
itkNewMacro
(
Self
);
itkTypeMacro
(
MRFEnergyFisherClassification
,
MRFEnergy
);
Gamma
g
;
void
SetNumberOfParameters
(
const
unsigned
int
nParameters
)
{
Superclass
::
SetNumberOfParameters
(
nParameters
);
this
->
m_Parameters
.
SetSize
(
nParameters
);
this
->
Modified
();
}
double
GetSingleValue
(
const
InputImagePixelType
&
value1
,
const
LabelledImagePixelType
&
value2
)
{
if
((
unsigned
int
)
value2
>=
this
->
GetNumberOfParameters
()
/
3
)
{
itkExceptionMacro
(
<<
"Number of parameters does not correspond to number of classes"
);
}
double
val1
=
static_cast
<
double
>
(
value1
);
double
mu
=
this
->
m_Parameters
[
3
*
static_cast
<
double
>
(
value2
)];
double
l
=
this
->
m_Parameters
[
3
*
static_cast
<
double
>
(
value2
)
+
1
];
double
m
=
this
->
m_Parameters
[
3
*
static_cast
<
double
>
(
value2
)
+
2
];
double
result
=
-
vcl_log
((
g
.
gamma
(
l
+
m
)
/
(
g
.
gamma
(
l
)
*
g
.
gamma
(
m
)))
*
(
2
/
(
mu
))
*
(
vcl_sqrt
(
l
/
m
))
*
((
pow
((
vcl_sqrt
(
l
/
m
)
*
(
val1
/
mu
)),
((
2
*
l
)
-
1
)))
/
(
pow
(
1
+
(
vcl_sqrt
(
l
/
m
)
*
(
val1
/
mu
)
*
vcl_sqrt
(
l
/
m
)
*
(
val1
/
mu
)),
(
l
+
m
)))));
return
static_cast
<
double
>
(
result
);
}
protected
:
// The constructor and destructor.
MRFEnergyFisherClassification
()
{};
virtual
~
MRFEnergyFisherClassification
()
{};
// The constructor and destructor.
MRFEnergyFisherClassification
()
{};
virtual
~
MRFEnergyFisherClassification
()
{};
};
}
#endif
This diff is collapsed.
Click to expand it.
Testing/Code/Common/otbGammaTest.cxx
+
7
−
4
View file @
8c71a0e7
...
...
@@ -28,10 +28,13 @@ int otbGammaTest(int argc, char * argv[])
//Instantiation
GammaFunctionType
*
gam
=
new
GammaFunctionType
();
const
double
epsilon
=
0.0000000001
;
int
output
=
EXIT_SUCCESS
;
if
(
vcl_abs
(
gam
->
gamma
(
1
)
-
1
)
>
epsilon
)
return
EXIT_FAILURE
;
if
(
vcl_abs
(
gam
->
gamma
(
0.5
)
-
1.77245385091
)
>
epsilon
)
return
EXIT_FAILURE
;
if
(
vcl_abs
(
gam
->
gamma
(
4
)
-
6
)
>
epsilon
)
return
EXIT_FAILURE
;
if
(
vcl_abs
(
gam
->
gamma
(
1
)
-
1
)
>
epsilon
)
output
=
EXIT_FAILURE
;
if
(
vcl_abs
(
gam
->
gamma
(
0.5
)
-
1.77245385091
)
>
epsilon
)
output
=
EXIT_FAILURE
;
if
(
vcl_abs
(
gam
->
gamma
(
4
)
-
6
)
>
epsilon
)
output
=
EXIT_FAILURE
;
return
EXIT_SUCCESS
;
delete
gam
;
return
output
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment