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
Container registry
Model registry
Operate
Environments
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
Antoine Belvire
otb
Commits
f6d25979
Commit
f6d25979
authored
16 years ago
by
Cyrille Valladeau
Browse files
Options
Downloads
Patches
Plain Diff
STYLE : code factorization
parent
24da2eb1
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/FeatureExtraction/otbAngularSecondMomentumTextureFunctor.h
+7
-57
7 additions, 57 deletions
...eatureExtraction/otbAngularSecondMomentumTextureFunctor.h
Code/FeatureExtraction/otbTextureFunctorBase.h
+71
-1
71 additions, 1 deletion
Code/FeatureExtraction/otbTextureFunctorBase.h
with
78 additions
and
58 deletions
Code/FeatureExtraction/otbAngularSecondMomentumTextureFunctor.h
+
7
−
57
View file @
f6d25979
...
...
@@ -48,74 +48,24 @@ public:
typedef
TIterInput1
IterType1
;
typedef
TIterInput2
IterType2
;
typedef
TOutput
OutputType
;
typedef
typename
IterType1
::
OffsetType
OffsetType
;
typedef
typename
IterType1
::
RadiusType
RadiusType
;
typedef
typename
IterType1
::
InternalPixelType
InternalPixelType
;
typedef
typename
IterType1
::
ImageType
ImageType
;
typedef
itk
::
Neighborhood
<
InternalPixelType
,
::
itk
::
GetImageDimension
<
ImageType
>::
ImageDimension
>
NeighborhoodType
;
typedef
std
::
vector
<
double
>
DoubleVectorType
;
typedef
std
::
vector
<
int
>
IntVectorType
;
typedef
std
::
vector
<
IntVectorType
>
IntVectorVectorType
;
virtual
double
ComputeOverSingleChannel
(
const
NeighborhoodType
&
neigh
,
const
NeighborhoodType
&
neighOff
)
{
DoubleVectorType
binsLength
=
this
->
StatComputation
(
neigh
,
neighOff
);
this
->
ComputeJointHistogram
(
neigh
,
neighOff
);
double
out
=
0.
;
RadiusType
radius
=
neigh
.
GetRadius
();
double
area
=
static_cast
<
double
>
(
neigh
.
GetSize
()[
0
]
*
neigh
.
GetSize
()[
1
]);
double
areaInv
=
1
/
area
;
OffsetType
offset
;
offset
.
Fill
(
0
);
OffsetType
offsetOff
;
OffsetType
offsetOffInit
;
offsetOffInit
[
0
]
=
-
radius
[
0
]
+
this
->
GetOffset
()[
0
]
-
1
;
offsetOffInit
[
1
]
=
-
radius
[
1
]
+
this
->
GetOffset
()[
1
]
-
1
;
int
histoIdX
=
0
;
int
histoIdY
=
0
;
double
out
=
0.
;
IntVectorType
histoTemp
;
IntVectorVectorType
histo
;
if
(
binsLength
[
0
]
!=
0
)
histoTemp
=
IntVectorType
(
vcl_floor
(
static_cast
<
double
>
(
this
->
GetMaxi
()
-
this
->
GetMini
())
/
binsLength
[
0
])
+
1.
,
0
);
else
histoTemp
=
IntVectorType
(
1
,
0
);
if
(
binsLength
[
1
]
!=
0
)
histo
=
IntVectorVectorType
(
vcl_floor
(
static_cast
<
double
>
(
this
->
GetMaxiOff
()
-
this
->
GetMiniOff
())
/
binsLength
[
1
])
+
1.
,
histoTemp
);
else
histo
=
IntVectorVectorType
(
1
,
histoTemp
);
offsetOff
=
offsetOffInit
;
for
(
int
l
=
-
static_cast
<
int
>
(
radius
[
0
]);
l
<=
static_cast
<
int
>
(
radius
[
0
]);
l
++
)
{
offsetOff
[
0
]
++
;
offsetOff
[
1
]
=
offsetOffInit
[
1
];
offset
[
0
]
=
l
;
for
(
int
k
=
-
static_cast
<
int
>
(
radius
[
1
]);
k
<=
static_cast
<
int
>
(
radius
[
1
]);
k
++
)
{
offsetOff
[
1
]
++
;
offset
[
1
]
=
k
;
histoIdX
=
0
;
histoIdY
=
0
;
if
(
binsLength
[
1
]
!=
0
)
histoIdX
=
static_cast
<
int
>
(
vcl_floor
(
(
static_cast
<
double
>
(
neighOff
[
offsetOff
])
-
this
->
GetMiniOff
())
/
static_cast
<
double
>
(
binsLength
[
1
])
));
if
(
binsLength
[
0
]
!=
0
)
histoIdY
=
static_cast
<
int
>
(
vcl_floor
(
(
static_cast
<
double
>
(
neigh
[
offset
])
-
this
->
GetMini
())
/
static_cast
<
double
>
(
binsLength
[
0
])
));
histo
[
histoIdX
][
histoIdY
]
++
;
}
}
for
(
unsigned
r
=
0
;
r
<
histo
.
size
();
r
++
)
for
(
unsigned
r
=
0
;
r
<
this
->
GetHisto
().
size
();
r
++
)
{
for
(
unsigned
s
=
0
;
s
<
his
to
[
r
].
size
();
s
++
)
for
(
unsigned
s
=
0
;
s
<
t
his
->
GetHisto
()
[
r
].
size
();
s
++
)
{
double
p
=
static_cast
<
double
>
(
his
to
[
r
][
s
])
*
areaInv
;
double
p
=
static_cast
<
double
>
(
t
his
->
GetHisto
()
[
r
][
s
])
*
areaInv
;
out
+=
vcl_pow
(
p
,
2
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Code/FeatureExtraction/otbTextureFunctorBase.h
+
71
−
1
View file @
f6d25979
...
...
@@ -54,6 +54,9 @@ public:
m_MeanOff
=
0.
;
m_Std
=
0.
;
m_StdOff
=
0.
;
m_NeighBinLength
=
0
;
m_OffsetBinLength
=
0
;
m_Histo
.
clear
();
};
~
TextureFunctorBase
()
{};
...
...
@@ -67,6 +70,9 @@ public:
typedef
typename
IterType1
::
ImageType
ImageType
;
typedef
itk
::
Neighborhood
<
InternalPixelType
,
::
itk
::
GetImageDimension
<
ImageType
>::
ImageDimension
>
NeighborhoodType
;
typedef
std
::
vector
<
double
>
DoubleVectorType
;
typedef
std
::
vector
<
int
>
IntVectorType
;
typedef
std
::
vector
<
IntVectorType
>
IntVectorVectorType
;
void
SetOffset
(
OffsetType
off
){
m_Offset
=
off
;
};
OffsetType
GetOffset
(){
return
m_Offset
;
};
...
...
@@ -77,7 +83,10 @@ public:
double
GetMean
(){
return
m_Mean
;
};
double
GetMeanOff
(){
return
m_MeanOff
;
};
double
GetStd
(){
return
m_Std
;
};
double
GetStdOff
(){
return
m_StdOff
;
};
double
GetStdOff
(){
return
m_StdOff
;};
double
GetNeighBinLength
(){
return
m_NeighBinLength
;
};
double
GetOffsetBinLength
(){
return
m_OffsetBinLength
;
};
IntVectorVectorType
GetHisto
(){
return
m_Histo
;
};
/** Computes the histogram bins using Scott formula, plus min/max, means, stds */
DoubleVectorType
StatComputation
(
const
NeighborhoodType
&
neigh
,
const
NeighborhoodType
&
neighOff
)
...
...
@@ -153,6 +162,9 @@ public:
output
.
push_back
(
scottCoef
*
binLength
);
output
.
push_back
(
scottCoef
*
binLengthOff
);
m_NeighBinLength
=
scottCoef
*
binLength
;
m_OffsetBinLength
=
scottCoef
*
binLengthOff
;
return
output
;
}
...
...
@@ -197,6 +209,59 @@ public:
return
outPix
;
}
void
ComputeJointHistogram
(
const
NeighborhoodType
&
neigh
,
const
NeighborhoodType
&
neighOff
)
{
DoubleVectorType
binsLength
=
this
->
StatComputation
(
neigh
,
neighOff
);
RadiusType
radius
=
neigh
.
GetRadius
();
double
area
=
static_cast
<
double
>
(
neigh
.
GetSize
()[
0
]
*
neigh
.
GetSize
()[
1
]);
double
areaInv
=
1
/
area
;
OffsetType
offset
;
offset
.
Fill
(
0
);
OffsetType
offsetOff
;
OffsetType
offsetOffInit
;
offsetOffInit
[
0
]
=
-
radius
[
0
]
+
this
->
GetOffset
()[
0
]
-
1
;
offsetOffInit
[
1
]
=
-
radius
[
1
]
+
this
->
GetOffset
()[
1
]
-
1
;
int
histoIdX
=
0
;
int
histoIdY
=
0
;
double
out
=
0.
;
IntVectorType
histoTemp
;
if
(
binsLength
[
0
]
!=
0
)
histoTemp
=
IntVectorType
(
vcl_floor
(
static_cast
<
double
>
(
this
->
GetMaxi
()
-
this
->
GetMini
())
/
m_NeighBinLength
)
+
1.
,
0
);
else
histoTemp
=
IntVectorType
(
1
,
0
);
if
(
binsLength
[
1
]
!=
0
)
m_Histo
=
IntVectorVectorType
(
vcl_floor
(
static_cast
<
double
>
(
this
->
GetMaxiOff
()
-
this
->
GetMiniOff
())
/
m_OffsetBinLength
)
+
1.
,
histoTemp
);
else
m_Histo
=
IntVectorVectorType
(
1
,
histoTemp
);
offsetOff
=
offsetOffInit
;
for
(
int
l
=
-
static_cast
<
int
>
(
radius
[
0
]);
l
<=
static_cast
<
int
>
(
radius
[
0
]);
l
++
)
{
offsetOff
[
0
]
++
;
offsetOff
[
1
]
=
offsetOffInit
[
1
];
offset
[
0
]
=
l
;
for
(
int
k
=
-
static_cast
<
int
>
(
radius
[
1
]);
k
<=
static_cast
<
int
>
(
radius
[
1
]);
k
++
)
{
offsetOff
[
1
]
++
;
offset
[
1
]
=
k
;
histoIdX
=
0
;
histoIdY
=
0
;
if
(
binsLength
[
1
]
!=
0
)
histoIdX
=
static_cast
<
int
>
(
vcl_floor
(
(
static_cast
<
double
>
(
neighOff
[
offsetOff
])
-
this
->
GetMiniOff
())
/
static_cast
<
double
>
(
m_OffsetBinLength
)
));
if
(
binsLength
[
0
]
!=
0
)
histoIdY
=
static_cast
<
int
>
(
vcl_floor
(
(
static_cast
<
double
>
(
neigh
[
offset
])
-
this
->
GetMini
())
/
static_cast
<
double
>
(
m_NeighBinLength
)
));
m_Histo
[
histoIdX
][
histoIdY
]
++
;
}
}
}
virtual
double
ComputeOverSingleChannel
(
const
NeighborhoodType
&
neigh
,
const
NeighborhoodType
&
neighOff
)
=
0
;
private
:
...
...
@@ -213,6 +278,11 @@ public:
/** Stores standard deviation of neighborhood+offset */
double
m_Std
;
double
m_StdOff
;
/** Bins length */
double
m_NeighBinLength
;
double
m_OffsetBinLength
;
/** Joint histogramm */
IntVectorVectorType
m_Histo
;
};
...
...
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