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
Julien Cabieces
otb
Commits
f219063a
Commit
f219063a
authored
17 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
Code for VectorImageToIntensityImageFilter
parent
ce211098
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/otbVectorImageToIntensityImageFilter.h
+104
-0
104 additions, 0 deletions
Code/BasicFilters/otbVectorImageToIntensityImageFilter.h
Code/BasicFilters/otbVectorImageToIntensityImageFilter.txx
+93
-0
93 additions, 0 deletions
Code/BasicFilters/otbVectorImageToIntensityImageFilter.txx
with
197 additions
and
0 deletions
Code/BasicFilters/otbVectorImageToIntensityImageFilter.h
0 → 100644
+
104
−
0
View file @
f219063a
/*=========================================================================
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.
=========================================================================*/
#ifndef _otbVectorImageToIntensityImageFilter_h
#define _otbVectorImageToIntensityImageFilter_h
#include
"itkImageToImageFilter.h"
namespace
otb
{
/** \class VectorImageToIntensityImageFilter
* \brief This filter implements the computation of the mean of the spectral values of each pixel.
*
* The spectral mean
* is defined as:
*
* \f[SM = \frac{1}{n_{b}} \times {\sum_{b=1}^{n_{b}}p(b) \f]
* with \f$b\f$ being the spectral band and \f$p\f$
* the current pixel.
*
* Since the spectral mean deals with multi-bands image, the InputImage pixels are suposed to
* support the [] operator, and the input image to support the GetNumberOfComponentsPerPixel() method.
*
* \sa VectorImage
*
* This filter is implemented as a multithreaded filter.
*
* \ingroup IntensityImageFilters
* \ingroup Threading
* \ingroup Streamed
*/
template
<
class
TInputImage
,
class
TOutputImage
>
class
ITK_EXPORT
VectorImageToIntensityImageFilter
:
public
itk
::
ImageToImageFilter
<
TInputImage
,
TOutputImage
>
{
public:
/** Standard typedefs */
typedef
VectorImageToIntensityImageFilter
Self
;
typedef
itk
::
ImageToImageFilter
<
TInputImage
,
TOutputImage
>
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Type macro */
itkNewMacro
(
Self
);
/** Creation through object factory macro */
itkTypeMacro
(
VectorImageToIntensityImageFilter
,
itk
::
ImageToImageFilter
);
/** Template parameters typedefs */
typedef
TInputImage
InputImageType
;
typedef
typename
InputImageType
::
ConstPointer
InputImageConstPointerType
;
typedef
typename
InputImageType
::
RegionType
InputImageRegionType
;
typedef
typename
InputImageType
::
PixelType
InputPixelType
;
typedef
TOutputImage
OutputImageType
;
typedef
typename
OutputImageType
::
Pointer
OutputImagePointerType
;
typedef
typename
OutputImageType
::
RegionType
OutputImageRegionType
;
typedef
typename
OutputImageType
::
PixelType
OutputPixelType
;
protected:
/** Constructor */
VectorImageToIntensityImageFilter
();
/** Destructor */
virtual
~
VectorImageToIntensityImageFilter
()
{};
/**PrintSelf method */
virtual
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
/** VectorImageToIntensityImageFilter can be implemented as a multithreaded filter.
* Therefore, this implementation provides a ThreadedGenerateData() routine
* which is called for each processing thread. The output image data is
* allocated automatically by the superclass prior to calling
* ThreadedGenerateData(). ThreadedGenerateData can only write to the
* portion of the output image specified by the parameter
* "outputRegionForThread"
*
* \sa ImageToImageFilter::ThreadedGenerateData(),
* ImageToImageFilter::GenerateData() */
void
ThreadedGenerateData
(
const
OutputImageRegionType
&
outputRegionForThread
,
int
threadId
);
private
:
VectorImageToIntensityImageFilter
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
};
}
// End namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include
"otbVectorImageToIntensityImageFilter.txx"
#endif
#endif
This diff is collapsed.
Click to expand it.
Code/BasicFilters/otbVectorImageToIntensityImageFilter.txx
0 → 100644
+
93
−
0
View file @
f219063a
/*=========================================================================
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.
=========================================================================*/
#ifndef _otbVectorImageToIntensityImageFilter_txx
#define _otbVectorImageToIntensityImageFilter_txx
#include "otbVectorImageToIntensityImageFilter.h"
#include "itkImageRegionIterator.h"
#include "itkImageRegionConstIterator.h"
#include "itkProgressReporter.h"
#include "otbMacro.h"
#include "otbMath.h"
namespace otb
{
/**
* Constructor
*/
template <class TInputImage, class TOutputImage>
VectorImageToIntensityImageFilter<TInputImage,TOutputImage>
::VectorImageToIntensityImageFilter()
{
}
template <class TInputImage, class TOutputImage>
void
VectorImageToIntensityImageFilter<TInputImage,TOutputImage>
::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,int threadId)
{
InputImageConstPointerType inputPtr = this->GetInput();
OutputImagePointerType outputPtr = this->GetOutput();
// Define the portion of the input to walk for this thread, using
// the CallCopyOutputRegionToInputRegion method allows for the input
// and output images to be different dimensions
InputImageRegionType inputRegionForThread;
this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
// Define the iterators
itk::ImageRegionConstIterator<InputImageType> inputIt(inputPtr, inputRegionForThread);
itk::ImageRegionIterator<OutputImageType> outputIt(outputPtr, outputRegionForThread);
itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
inputIt.GoToBegin();
outputIt.GoToBegin();
while(!inputIt.IsAtEnd() && !outputIt.IsAtEnd())
{
double sum=0.0;
InputPixelType pixel = inputIt.Get();
for (unsigned int i=0; i<pixel.Size(); i++)
{
sum += pixel[i];
}
sum /= pixel.Size() ;
outputIt.Set(static_cast<OutputPixelType>(sum));
++inputIt;
++outputIt;
progress.CompletedPixel(); // potential exception thrown here
}
}
/**
* PrintSelf Method
*/
template <class TInputImage, class TOutputImage>
void
VectorImageToIntensityImageFilter<TInputImage,TOutputImage>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
}
} // End namespace otb
#endif
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