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
otb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
273
Issues
273
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Main Repositories
otb
Commits
8a1a5758
Commit
8a1a5758
authored
Jan 06, 2010
by
Manuel Grizonnet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ADD: add labelMap example 1 in progress
parent
c2e83b44
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
146 additions
and
1 deletion
+146
-1
Examples/OBIA/CMakeLists.txt
Examples/OBIA/CMakeLists.txt
+5
-1
Examples/OBIA/otbRadiometricAttributesLabelMapFilterExample.cxx
...es/OBIA/otbRadiometricAttributesLabelMapFilterExample.cxx
+141
-0
No files found.
Examples/OBIA/CMakeLists.txt
View file @
8a1a5758
...
...
@@ -10,6 +10,8 @@ TARGET_LINK_LIBRARIES(ShapeAttributeComputation OTBCommon OTBIO ${OTB_IO_UTILITI
ADD_EXECUTABLE
(
KeepNObjects KeepNObjects.cxx
)
TARGET_LINK_LIBRARIES
(
KeepNObjects OTBCommon OTBIO
${
OTB_IO_UTILITIES_DEPENDENT_LIBRARIES
}
)
ADD_EXECUTABLE
(
RadiometricAttributesLabelMapFilterExample otbRadiometricAttributesLabelMapFilterExample.cxx
)
TARGET_LINK_LIBRARIES
(
RadiometricAttributesLabelMapFilterExample OTBCommon OTBIO OTBBasicFilters OTBSpatialReasoning OTBFeatureExtraction OTBLearning
${
OTB_IO_UTILITIES_DEPENDENT_LIBRARIES
}
)
IF
(
NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING
)
...
...
@@ -46,7 +48,9 @@ ADD_TEST(trTeOBIAShapeAttributeComputationTest ${EXE_TESTS}
${
INPUTDATA
}
/MSLabeledOutput.tif
${
TEMP
}
/OBIAShapeAttribute.txt
)
#need to add the test of radiometric labelmap filter
INCLUDE_DIRECTORIES
(
${
OTB_SOURCE_DIR
}
/Testing/Code
)
ADD_EXECUTABLE
(
otbOBIAExamplesTests otbOBIAExamplesTests.cxx
)
TARGET_LINK_LIBRARIES
(
otbOBIAExamplesTests ITKAlgorithms ITKStatistics ITKNumerics OTBBasicFilters OTBCommon OTBDisparityMap OTBIO OTBSpatialReasoning OTBChangeDetection OTBFeatureExtraction OTBLearning OTBMultiScale OTBFusion OTBTesting
)
...
...
Examples/OBIA/otbRadiometricAttributesLabelMapFilterExample.cxx
0 → 100755
View file @
8a1a5758
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
// Software Guide : BeginCommandLineArgs
// INPUTS: {XX.tif}
// OUTPUTS: {XX.txt}
// Software Guide : EndCommandLineArgs
// Software Guide : BeginLatex
//
// This example shows the basic approch to perform
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbMeanShiftImageFilter.h"
#include "itkLabelImageToLabelMapFilter.h"
#include "otbAttributesMapLabelObject.h"
#include "itkLabelMap.h"
#include "otbShapeAttributesLabelMapFilter.h"
#include "otbStatisticsAttributesLabelMapFilter.h"
#include "otbRadiometricAttributesLabelMapFilter.h"
#include "otbAttributesMapOpeningLabelMapFilter.h"
#include "itkLabelMapToLabelImageFilter.h"
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
10
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" reffname outfname attribute_name lowerThan tresh spatialRadius rangeRadius minregionsize scale"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
const
char
*
reffname
=
argv
[
1
];
const
char
*
outfname
=
argv
[
2
];
const
char
*
attr
=
argv
[
3
];
bool
lowerThan
=
atoi
(
argv
[
4
]);
double
thresh
=
atof
(
argv
[
5
]);
const
unsigned
int
spatialRadius
=
atoi
(
argv
[
6
]);
const
double
rangeRadius
=
atof
(
argv
[
7
]);
const
unsigned
int
minRegionSize
=
atoi
(
argv
[
8
]);
const
double
scale
=
atoi
(
argv
[
9
]);
const
unsigned
int
Dimension
=
2
;
// Labeled image type
typedef
unsigned
short
LabelType
;
typedef
double
PixelType
;
typedef
otb
::
Image
<
LabelType
,
Dimension
>
LabeledImageType
;
typedef
otb
::
Image
<
PixelType
,
Dimension
>
ImageType
;
typedef
otb
::
VectorImage
<
PixelType
,
Dimension
>
VectorImageType
;
typedef
otb
::
ImageFileReader
<
LabeledImageType
>
LabeledReaderType
;
typedef
otb
::
ImageFileReader
<
ImageType
>
ReaderType
;
typedef
otb
::
ImageFileReader
<
VectorImageType
>
VectorReaderType
;
typedef
otb
::
ImageFileWriter
<
LabeledImageType
>
WriterType
;
// Label map typedef
typedef
otb
::
AttributesMapLabelObject
<
LabelType
,
Dimension
,
double
>
LabelObjectType
;
typedef
itk
::
LabelMap
<
LabelObjectType
>
LabelMapType
;
typedef
itk
::
LabelImageToLabelMapFilter
<
LabeledImageType
,
LabelMapType
>
LabelMapFilterType
;
typedef
otb
::
ShapeAttributesLabelMapFilter
<
LabelMapType
>
ShapeLabelMapFilterType
;
typedef
otb
::
StatisticsAttributesLabelMapFilter
<
LabelMapType
,
ImageType
>
StatisticsLabelMapFilterType
;
typedef
otb
::
RadiometricAttributesLabelMapFilter
<
LabelMapType
,
VectorImageType
>
RadiometricLabelMapFilterType
;
typedef
otb
::
AttributesMapOpeningLabelMapFilter
<
LabelMapType
>
OpeningLabelMapFilterType
;
typedef
itk
::
LabelMapToLabelImageFilter
<
LabelMapType
,
LabeledImageType
>
LabelMapToLabeledImageFilterType
;
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
reader
->
SetFileName
(
reffname
);
//std::cout << reffname << std::endl;
//reader->Update();
//std::cout << reffname << std::endl;
VectorReaderType
::
Pointer
vreader
=
VectorReaderType
::
New
();
vreader
->
SetFileName
(
reffname
);
//Segment the ref image using Mean Shift
typedef
otb
::
MeanShiftImageFilter
<
ImageType
,
ImageType
,
LabeledImageType
>
FilterType
;
FilterType
::
Pointer
filter
=
FilterType
::
New
();
filter
->
SetSpatialRadius
(
spatialRadius
);
filter
->
SetRangeRadius
(
rangeRadius
);
filter
->
SetMinimumRegionSize
(
minRegionSize
);
filter
->
SetScale
(
scale
);
filter
->
SetInput
(
reader
->
GetOutput
());
LabelMapFilterType
::
Pointer
labelMapFilter
=
LabelMapFilterType
::
New
();
labelMapFilter
->
SetInput
(
filter
->
GetLabeledClusteredOutput
());
labelMapFilter
->
SetBackgroundValue
(
itk
::
NumericTraits
<
LabelType
>::
max
());
ShapeLabelMapFilterType
::
Pointer
shapeLabelMapFilter
=
ShapeLabelMapFilterType
::
New
();
shapeLabelMapFilter
->
SetInput
(
labelMapFilter
->
GetOutput
());
StatisticsLabelMapFilterType
::
Pointer
statisticsLabelMapFilter
=
StatisticsLabelMapFilterType
::
New
();
statisticsLabelMapFilter
->
SetInput1
(
shapeLabelMapFilter
->
GetOutput
());
statisticsLabelMapFilter
->
SetInput2
(
reader
->
GetOutput
());
statisticsLabelMapFilter
->
Update
();
RadiometricLabelMapFilterType
::
Pointer
radiometricLabelMapFilter
=
RadiometricLabelMapFilterType
::
New
();
radiometricLabelMapFilter
->
SetInput1
(
statisticsLabelMapFilter
->
GetOutput
());
radiometricLabelMapFilter
->
SetInput2
(
vreader
->
GetOutput
());
//radiometricLabelMapFilter->SetReducedAttributeSet(false);
radiometricLabelMapFilter
->
SetRedChannelIndex
(
1
);
radiometricLabelMapFilter
->
SetNIRChannelIndex
(
2
);
radiometricLabelMapFilter
->
Update
();
OpeningLabelMapFilterType
::
Pointer
opening
=
OpeningLabelMapFilterType
::
New
();
opening
->
SetInput
(
radiometricLabelMapFilter
->
GetOutput
());
opening
->
SetAttributeName
(
attr
);
opening
->
SetReverseOrdering
(
lowerThan
);
opening
->
SetLambda
(
thresh
);
LabelMapToLabeledImageFilterType
::
Pointer
labelMap2LabeledImage
=
LabelMapToLabeledImageFilterType
::
New
();
labelMap2LabeledImage
->
SetInput
(
opening
->
GetOutput
());
WriterType
::
Pointer
writer
=
WriterType
::
New
();
writer
->
SetFileName
(
outfname
);
writer
->
SetInput
(
labelMap2LabeledImage
->
GetOutput
());
writer
->
Update
();
return
EXIT_SUCCESS
;
}
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