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
922f6f27
Commit
922f6f27
authored
12 years ago
by
Sebastien Harasse
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Region merging: adding clustered output
parent
08305dba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/BasicFilters/otbLabelImageRegionMergingFilter.h
+6
-0
6 additions, 0 deletions
Code/BasicFilters/otbLabelImageRegionMergingFilter.h
Code/BasicFilters/otbLabelImageRegionMergingFilter.txx
+45
-1
45 additions, 1 deletion
Code/BasicFilters/otbLabelImageRegionMergingFilter.txx
with
51 additions
and
1 deletion
Code/BasicFilters/otbLabelImageRegionMergingFilter.h
+
6
−
0
View file @
922f6f27
...
...
@@ -78,6 +78,8 @@ public:
typedef
typename
OutputImageType
::
PixelType
OutputPixelType
;
typedef
typename
OutputImageType
::
RegionType
OutputRegionType
;
typedef
TInputSpectralImage
OutputClusteredImageType
;
itkStaticConstMacro
(
ImageDimension
,
unsigned
int
,
InputLabelImageType
::
ImageDimension
);
/** LabelMap typedefs */
...
...
@@ -105,6 +107,10 @@ public:
const
OutputLabelImageType
*
GetLabelOutput
()
const
;
/** Returns the image of region labels */
OutputLabelImageType
*
GetLabelOutput
();
/** Returns the const clustered output image, with one spectral value per region */
const
OutputClusteredImageType
*
GetClusteredOutput
()
const
;
/** Returns the clustered output image, with one spectral value per region */
OutputClusteredImageType
*
GetClusteredOutput
();
void
SetInputLabelImage
(
const
InputLabelImageType
*
labelImage
);
void
SetInputSpectralImage
(
const
InputSpectralImageType
*
spectralImage
);
...
...
This diff is collapsed.
Click to expand it.
Code/BasicFilters/otbLabelImageRegionMergingFilter.txx
+
45
−
1
View file @
922f6f27
...
...
@@ -35,6 +35,10 @@ LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabe
this->SetNumberOfRequiredInputs( 2 );
this->SetNumberOfOutputs(2);
this->SetNthOutput(0, OutputLabelImageType::New());
this->SetNthOutput(1, OutputClusteredImageType::New());
}
template <class TInputLabelImage, class TInputSpectralImage, class TOutputLabelImage>
...
...
@@ -103,6 +107,30 @@ LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabe
return static_cast<OutputLabelImageType *>(this->itk::ProcessObject::GetOutput(0));
}
template <class TInputLabelImage, class TInputSpectralImage, class TOutputLabelImage>
typename LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabelImage>::OutputClusteredImageType *
LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabelImage>
::GetClusteredOutput()
{
if (this->GetNumberOfOutputs() < 2)
{
return 0;
}
return static_cast<OutputClusteredImageType *>(this->itk::ProcessObject::GetOutput(1));
}
template <class TInputLabelImage, class TInputSpectralImage, class TOutputLabelImage>
const typename LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabelImage>::OutputClusteredImageType *
LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabelImage>
::GetClusteredOutput() const
{
if (this->GetNumberOfOutputs() < 2)
{
return 0;
}
return static_cast<OutputClusteredImageType *>(this->itk::ProcessObject::GetOutput(1));
}
template <class TInputLabelImage, class TInputSpectralImage, class TOutputLabelImage>
void
...
...
@@ -113,10 +141,13 @@ LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabe
typename InputSpectralImageType::Pointer spectralImage = this->GetInputSpectralImage();
typename InputLabelImageType::Pointer inputLabelImage = this->GetInputLabelImage();
typename OutputLabelImageType::Pointer outputLabelImage = this->GetLabelOutput();
typename OutputClusteredImageType::Pointer outputClusteredImage = this->GetClusteredOutput();
// Allocate
the
output
// Allocate output
outputLabelImage->SetBufferedRegion( outputLabelImage->GetRequestedRegion() );
outputLabelImage->Allocate();
outputClusteredImage->SetBufferedRegion( outputClusteredImage->GetRequestedRegion() );
outputClusteredImage->Allocate();
m_NumberOfComponentsPerPixel = spectralImage->GetNumberOfComponentsPerPixel();
...
...
@@ -337,6 +368,19 @@ LabelImageRegionMergingFilter<TInputLabelImage, TInputSpectralImage, TOutputLabe
} // end of main iteration loop
std::cout << "merge iterations: " << mergeIterations << std::endl;
std::cout << "number of label objects: " << regionCount << std::endl;
// Generate clustered output
itk::ImageRegionIterator<OutputClusteredImageType> outputClusteredIt(outputClusteredImage, outputClusteredImage->GetRequestedRegion() );
outputClusteredIt.GoToBegin();
outputIt.GoToBegin();
while( !outputClusteredIt.IsAtEnd() )
{
LabelType label = outputIt.Get();
const SpectralPixelType & p = m_Modes[ label ];
outputClusteredIt.Set(p);
++outputClusteredIt;
++outputIt;
}
}
template <class TInputLabelImage, class TInputSpectralImage, class TOutputLabelImage>
...
...
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