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
c9feeed7
Commit
c9feeed7
authored
18 years ago
by
Jordi Inglada
Browse files
Options
Downloads
Patches
Plain Diff
Hu for images
parent
b87ea8e9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Examples/FeatureExtraction/CMakeLists.txt
+2
-0
2 additions, 0 deletions
Examples/FeatureExtraction/CMakeLists.txt
Examples/FeatureExtraction/HuMomentImageExample.cxx
+154
-0
154 additions, 0 deletions
Examples/FeatureExtraction/HuMomentImageExample.cxx
with
156 additions
and
0 deletions
Examples/FeatureExtraction/CMakeLists.txt
+
2
−
0
View file @
c9feeed7
...
...
@@ -16,4 +16,6 @@ TARGET_LINK_LIBRARIES(ComplexMomentImageExample OTBCommon OTBIO ITKCommon ITKIO
ADD_EXECUTABLE
(
ComplexMomentPathExample ComplexMomentPathExample.cxx
)
TARGET_LINK_LIBRARIES
(
ComplexMomentPathExample OTBCommon OTBIO ITKCommon ITKIO ITKNumerics ITKBasicFilters ITKCommon ITKStatistics itkvnl_inst itkvnl_algo itkvnl itkvcl itknetlib itksys ITKNrrdIO itkpng itktiff itkjpeg8 itkjpeg12 itkjpeg16 ITKMetaIO itkzlib ITKDICOMParser ITKEXPAT
)
ADD_EXECUTABLE
(
HuMomentImageExample HuMomentImageExample.cxx
)
TARGET_LINK_LIBRARIES
(
HuMomentImageExample OTBCommon OTBIO ITKCommon ITKIO ITKNumerics ITKBasicFilters ITKCommon ITKStatistics itkvnl_inst itkvnl_algo itkvnl itkvcl itknetlib itksys ITKNrrdIO itkpng itktiff itkjpeg8 itkjpeg12 itkjpeg16 ITKMetaIO itkzlib ITKDICOMParser ITKEXPAT
)
This diff is collapsed.
Click to expand it.
Examples/FeatureExtraction/HuMomentImageExample.cxx
0 → 100644
+
154
−
0
View file @
c9feeed7
/*=========================================================================
Program : OTB (ORFEO ToolBox)
Authors : CNES - J. Inglada
Language : C++
Date : 13 April 2006
Version :
Role :
$Id:$
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include
"itkExceptionObject.h"
#include
"itkImage.h"
#include
"otbImageFileReader.h"
// Software Guide : BeginCommandLineArgs
// INPUTS: {ROISpot5.png}
// 2
// Software Guide : EndCommandLineArgs
// Software Guide : BeginLatex
//
// This example illustrates the use of the \doxygen{otb::HuMomentImageFunction}.
//
// The first step required to use this filter is to include its header file.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
#include
"otbHuImageFunction.h"
// Software Guide : EndCodeSnippet
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
3
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
<<
" inputImageFile "
;
std
::
cerr
<<
" moment_number"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
const
char
*
inputFilename
=
argv
[
1
];
unsigned
int
mNumber
((
unsigned
char
)
::
atoi
(
argv
[
2
]));
typedef
unsigned
char
InputPixelType
;
const
unsigned
int
Dimension
=
2
;
typedef
itk
::
Image
<
InputPixelType
,
Dimension
>
InputImageType
;
typedef
otb
::
ImageFileReader
<
InputImageType
>
ReaderType
;
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
reader
->
SetFileName
(
inputFilename
);
// Software Guide : BeginLatex
//
// The \doxygen{otb::HuImageFunction} is templated over the
// input image type and the output (real) type value, so we start by
// defining:
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
float
MomentType
;
typedef
otb
::
HuImageFunction
<
InputImageType
,
MomentType
>
HuType
;
HuType
::
Pointer
hmFunction
=
HuType
::
New
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
// We can choose the region and the pixel of the image which will
// used as coordinate origin
// for the moment computation
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
InputImageType
::
RegionType
region
;
InputImageType
::
SizeType
size
;
InputImageType
::
IndexType
start
;
start
[
0
]
=
0
;
start
[
1
]
=
0
;
size
[
0
]
=
50
;
size
[
1
]
=
50
;
reader
->
Update
();
InputImageType
::
Pointer
image
=
reader
->
GetOutput
();
region
.
SetIndex
(
start
);
region
.
SetSize
(
size
);
image
->
SetRegions
(
region
);
image
->
Update
();
InputImageType
::
IndexType
center
;
center
[
0
]
=
start
[
0
]
+
size
[
0
]
/
2
;
center
[
1
]
=
start
[
1
]
+
size
[
1
]
/
2
;
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// Next, we plug the input image into the complex moment fucntion
// and we set its parameters.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
hmFunction
->
SetInputImage
(
image
);
hmFunction
->
SetNumber
(
mNumber
);
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
// In order to get the value of the moment, we call the
// \code{EvaluateAtIndex} method.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
MomentType
Result
=
hmFunction
->
EvaluateAtIndex
(
center
);
std
::
cout
<<
"The moment of order "
<<
mNumber
<<
" is equal to "
<<
Result
<<
std
::
endl
;
// Software Guide : EndCodeSnippet
return
EXIT_SUCCESS
;
}
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