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
otbtf
Commits
181e57de
Commit
181e57de
authored
Oct 26, 2019
by
Cresson Remi
Browse files
ENH: new sample selection/extraction strategy (use nodata in selection or extraction)
parent
7c619e25
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/otbPatchesSelection.cxx
View file @
181e57de
...
...
@@ -236,23 +236,11 @@ public:
UInt8ImageType
::
IndexType
index
;
};
/*
* Apply the given function at each sampling location
*/
template
<
typename
TLambda
>
void
Apply
(
TLambda
lambda
)
{
if
(
GetParameterInt
(
"nockeck"
)
==
1
)
ApplyFast
(
lambda
);
else
ApplyWithCheck
(
lambda
);
}
/*
* Apply the given function at each sampling location, checking if the patch is valid or not
*/
template
<
typename
TLambda
>
void
Apply
WithCheck
(
TLambda
lambda
)
void
Apply
(
TLambda
lambda
)
{
// Explicit streaming over the morphed mask, based on the RAM parameter
...
...
@@ -260,7 +248,11 @@ public:
StreamingManagerType
::
Pointer
m_StreamingManager
=
StreamingManagerType
::
New
();
m_StreamingManager
->
SetAvailableRAMInMB
(
GetParameterInt
(
"ram"
));
UInt8ImageType
::
Pointer
inputImage
=
m_MorphoFilter
->
GetOutput
();
UInt8ImageType
::
Pointer
inputImage
;
if
(
GetParameterInt
(
"nockeck"
)
==
1
)
inputImage
=
GetParameterUInt8Image
(
"mask"
);
else
inputImage
=
m_MorphoFilter
->
GetOutput
();
UInt8ImageType
::
RegionType
entireRegion
=
inputImage
->
GetLargestPossibleRegion
();
entireRegion
.
ShrinkByRadius
(
m_Radius
);
m_StreamingManager
->
PrepareStreaming
(
inputImage
,
entireRegion
);
...
...
@@ -298,7 +290,7 @@ public:
// Compute coordinates
UInt8ImageType
::
PointType
geo
;
m_MorphoFilter
->
GetOutput
()
->
TransformIndexToPhysicalPoint
(
inIt
.
GetIndex
(),
geo
);
inputImage
->
TransformIndexToPhysicalPoint
(
inIt
.
GetIndex
(),
geo
);
DataNodeType
::
PointType
point
;
point
[
0
]
=
geo
[
0
];
point
[
1
]
=
geo
[
1
];
...
...
@@ -312,49 +304,6 @@ public:
}
}
/*
* Apply the given function at each sampling location, without checking the valid pixels under
*/
template
<
typename
TLambda
>
void
ApplyFast
(
TLambda
lambda
)
{
FloatVectorImageType
::
Pointer
inputImage
=
GetParameterFloatVectorImage
(
"in"
);
FloatVectorImageType
::
RegionType
entireRegion
=
inputImage
->
GetLargestPossibleRegion
();
entireRegion
.
ShrinkByRadius
(
m_Radius
);
FloatVectorImageType
::
IndexType
start
;
start
[
0
]
=
m_Radius
[
0
]
+
1
;
start
[
1
]
=
m_Radius
[
1
]
+
1
;
FloatVectorImageType
::
IndexType
pos
;
pos
.
Fill
(
0
);
FloatVectorImageType
::
IndexValueType
step
=
GetParameterInt
(
"grid.step"
);
typedef
itk
::
ImageRegionConstIteratorWithOnlyIndex
<
FloatVectorImageType
>
IteratorType
;
IteratorType
inIt
(
inputImage
,
entireRegion
);
for
(
inIt
.
GoToBegin
();
!
inIt
.
IsAtEnd
();
++
inIt
)
{
FloatVectorImageType
::
IndexType
idx
=
inIt
.
GetIndex
();
idx
[
0
]
-=
start
[
0
];
idx
[
1
]
-=
start
[
1
];
if
(
idx
[
0
]
%
step
==
0
&&
idx
[
1
]
%
step
==
0
)
{
// Update grid position
pos
[
0
]
=
idx
[
0
]
/
step
;
pos
[
1
]
=
idx
[
1
]
/
step
;
// Compute coordinates
FloatVectorImageType
::
PointType
geo
;
inputImage
->
TransformIndexToPhysicalPoint
(
inIt
.
GetIndex
(),
geo
);
DataNodeType
::
PointType
point
;
point
[
0
]
=
geo
[
0
];
point
[
1
]
=
geo
[
1
];
// Lambda call
lambda
(
pos
,
geo
);
}
}
}
/*
* Allocate a std::vector of sample bundle
*/
...
...
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