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
87075d48
Commit
87075d48
authored
17 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
Seam carving example (TODO: ajouter aux tests)
parent
13a3bf37
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
+4
-0
4 additions, 0 deletions
Examples/FeatureExtraction/CMakeLists.txt
Examples/FeatureExtraction/SeamCarvingExample.cxx
+177
-0
177 additions, 0 deletions
Examples/FeatureExtraction/SeamCarvingExample.cxx
with
181 additions
and
0 deletions
Examples/FeatureExtraction/CMakeLists.txt
+
4
−
0
View file @
87075d48
...
@@ -53,6 +53,10 @@ ADD_EXECUTABLE(ExtractRoadExample ExtractRoadExample.cxx)
...
@@ -53,6 +53,10 @@ ADD_EXECUTABLE(ExtractRoadExample ExtractRoadExample.cxx)
TARGET_LINK_LIBRARIES
(
ExtractRoadExample OTBIO OTBCommon OTBFeatureExtraction
TARGET_LINK_LIBRARIES
(
ExtractRoadExample OTBIO OTBCommon OTBFeatureExtraction
ITKCommon ITKBasicFilters
)
ITKCommon ITKBasicFilters
)
ADD_EXECUTABLE
(
SeamCarvingExample SeamCarvingExample.cxx
)
TARGET_LINK_LIBRARIES
(
SeamCarvingExample OTBIO OTBCommon OTBFeatureExtraction
ITKCommon ITKBasicFilters
)
IF
(
NOT OTB_DISABLE_CXX_TESTING AND NOT OTB_DISABLE_CXX_EXAMPLES_TESTING
)
IF
(
NOT OTB_DISABLE_CXX_TESTING AND NOT OTB_DISABLE_CXX_EXAMPLES_TESTING
)
SET
(
BASELINE
${
OTB_DATA_ROOT
}
/Baseline/Examples/FeatureExtraction
)
SET
(
BASELINE
${
OTB_DATA_ROOT
}
/Baseline/Examples/FeatureExtraction
)
...
...
This diff is collapsed.
Click to expand it.
Examples/FeatureExtraction/SeamCarvingExample.cxx
0 → 100644
+
177
−
0
View file @
87075d48
/*=========================================================================
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.
=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif
// Software Guide : BeginLatex
//
// This example illustrates the details of the seam carving operation.
// References to this method can be found in \cite{Avidan07}. This example
// details the use of \doxygen{otb}{ImageToCarvingPathFilter} and
// \doxygen{otb}{RemoveCarvingPathFilter}.
//
// Software Guide : EndLatex
// Software Guide : BeginCommandLineArgs
// INPUTS: {QB_Suburb.png}
// OUTPUTS: {SeamCarvingExampleOutput.png}
// 100
// Software Guide : EndCommandLineArgs
#include
"otbImage.h"
#include
"itkPolyLineParametricPath.h"
#include
"otbImageFileReader.h"
#include
"otbImageFileWriter.h"
#include
"itkGradientMagnitudeImageFilter.h"
#include
"itkRescaleIntensityImageFilter.h"
#include
"otbDrawPathFilter.h"
#include
"otbImageToCarvingPathFilter.h"
#include
"otbRemoveCarvingPathFilter.h"
#include
"itkImageDuplicator.h"
int
main
(
int
argc
,
char
**
argv
)
{
typedef
float
InputPixelType
;
typedef
unsigned
char
OutputPixelType
;
const
unsigned
int
Dimension
=
2
;
typedef
otb
::
Image
<
InputPixelType
,
Dimension
>
ImageType
;
typedef
otb
::
Image
<
OutputPixelType
,
Dimension
>
OutputImageType
;
typedef
itk
::
PolyLineParametricPath
<
Dimension
>
PathType
;
typedef
otb
::
ImageFileReader
<
ImageType
>
ReaderType
;
typedef
otb
::
ImageFileWriter
<
OutputImageType
>
WriterType
;
typedef
itk
::
RescaleIntensityImageFilter
<
ImageType
,
OutputImageType
>
RescalerType
;
ReaderType
::
Pointer
reader
=
ReaderType
::
New
();
WriterType
::
Pointer
writer
=
WriterType
::
New
();
RescalerType
::
Pointer
rescaler
=
RescalerType
::
New
();
const
char
*
filenamereader
=
argv
[
1
];
reader
->
SetFileName
(
filenamereader
);
const
char
*
filenamewriter
=
argv
[
2
];
writer
->
SetFileName
(
filenamewriter
);
int
iteration
=
atoi
(
argv
[
3
]);
// Software Guide : BeginLatex
//
// Energy is computed according to the gradient of the image, thus an
// \doxygen{itk}{GradientMagnitudeImageFilter} is instanciated
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
itk
::
GradientMagnitudeImageFilter
<
ImageType
,
ImageType
>
GradientType
;
GradientType
::
Pointer
gradient
=
GradientType
::
New
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The \doxygen{otb}{ImageToCarvingPathFilter} compute the path of minimum energy
// according to lines or columns of the image. Later, as we will choose the best option
// between the two, we need two of these filters.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
otb
::
ImageToCarvingPathFilter
<
ImageType
,
PathType
>
CarvingFilterType
;
CarvingFilterType
::
Pointer
carvingFilterVert
=
CarvingFilterType
::
New
();
CarvingFilterType
::
Pointer
carvingFilterHor
=
CarvingFilterType
::
New
();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
//
// The \doxygen{otb}{RemoveCarvingPathFilter} will really resize the image deleting
// the path.
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
typedef
otb
::
RemoveCarvingPathFilter
<
ImageType
,
PathType
,
ImageType
>
RemoveCarvingPathFilterType
;
RemoveCarvingPathFilterType
::
Pointer
removeCarvingPath
=
RemoveCarvingPathFilterType
::
New
();
// Software Guide : EndCodeSnippet
typedef
itk
::
ImageDuplicator
<
ImageType
>
duplicatorType
;
duplicatorType
::
Pointer
duplicator
=
duplicatorType
::
New
();
reader
->
Update
();
duplicator
->
SetInputImage
(
reader
->
GetOutput
());
duplicator
->
Update
();
double
energyVert
,
energyHor
;
for
(
int
i
=
0
;
i
<
iteration
;
i
++
)
{
std
::
cout
<<
"Iterations: "
<<
i
<<
std
::
endl
;
gradient
->
SetInput
(
duplicator
->
GetOutput
()
);
carvingFilterVert
->
SetInput
(
gradient
->
GetOutput
()
);
carvingFilterVert
->
SetDirection
(
0
);
carvingFilterVert
->
UpdateLargestPossibleRegion
();
energyVert
=
carvingFilterVert
->
GetEnergyPerPix
();
carvingFilterHor
->
SetInput
(
gradient
->
GetOutput
()
);
carvingFilterHor
->
SetDirection
(
1
);
carvingFilterHor
->
UpdateLargestPossibleRegion
();
energyHor
=
carvingFilterHor
->
GetEnergyPerPix
();
if
(
energyVert
<
energyHor
)
{
removeCarvingPath
->
SetInput
(
duplicator
->
GetOutput
()
);
removeCarvingPath
->
SetPathInput
(
carvingFilterVert
->
GetOutput
()
);
removeCarvingPath
->
SetDirection
(
0
);
removeCarvingPath
->
UpdateLargestPossibleRegion
();
}
else
{
removeCarvingPath
->
SetInput
(
duplicator
->
GetOutput
()
);
removeCarvingPath
->
SetPathInput
(
carvingFilterHor
->
GetOutput
()
);
removeCarvingPath
->
SetDirection
(
1
);
removeCarvingPath
->
UpdateLargestPossibleRegion
();
}
duplicator
->
SetInputImage
(
removeCarvingPath
->
GetOutput
());
duplicator
->
Update
();
}
rescaler
->
SetInput
(
duplicator
->
GetOutput
()
);
writer
->
SetInput
(
rescaler
->
GetOutput
()
);
writer
->
Update
();
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