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
c8b6a10a
Commit
c8b6a10a
authored
16 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Added a filter to handle channel extraction otb::Image<itk::Vector<PixelType,N>>
parent
a2cfed95
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
Code/Common/otbImageOfVectorsToMonoChannelExtractROI.h
+118
-0
118 additions, 0 deletions
Code/Common/otbImageOfVectorsToMonoChannelExtractROI.h
Code/Common/otbImageOfVectorsToMonoChannelExtractROI.txx
+123
-0
123 additions, 0 deletions
Code/Common/otbImageOfVectorsToMonoChannelExtractROI.txx
with
241 additions
and
0 deletions
Code/Common/otbImageOfVectorsToMonoChannelExtractROI.h
0 → 100644
+
118
−
0
View file @
c8b6a10a
/*=========================================================================
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 __otbImageOfVectorsToMonoChannelExtractROI_h
#define __otbImageOfVectorsToMonoChannelExtractROI_h
#include
"otbExtractROIBase.h"
#include
"otbImage.h"
#include
"otbVectorImage.h"
#include
"itkMacro.h"
namespace
otb
{
/** \class ImageOfVectorsToMonoChannelExtractROI
* \brief
* \todo Document this class
*/
template
<
class
TInputImage
,
class
TOutputImage
>
class
ITK_EXPORT
ImageOfVectorsToMonoChannelExtractROI
:
public
ExtractROIBase
<
TInputImage
,
TOutputImage
>
{
public:
/** Standard class typedefs. */
typedef
ImageOfVectorsToMonoChannelExtractROI
Self
;
typedef
ExtractROIBase
<
TInputImage
,
TOutputImage
>
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Method for creation through the object factory. */
itkNewMacro
(
Self
);
/** Run-time type information (and related methods). */
itkTypeMacro
(
ImageOfVectorsToMonoChannelExtractROI
,
ExtractROIBase
);
/** Image type information. */
typedef
typename
Superclass
::
InputImageType
InputImageType
;
typedef
typename
Superclass
::
OutputImageType
OutputImageType
;
/** Pixel type information */
typedef
typename
OutputImageType
::
ValueType
OutputValueType
;
/** Typedef to describe the output and input image region types. */
typedef
typename
OutputImageType
::
RegionType
OutputImageRegionType
;
typedef
typename
InputImageType
::
RegionType
InputImageRegionType
;
/** Typedef to describe the type of pixel. */
typedef
typename
OutputImageType
::
PixelType
OutputImagePixelType
;
typedef
typename
InputImageType
::
PixelType
InputImagePixelType
;
/** Typedef to describe the output and input image index and size types. */
typedef
typename
OutputImageType
::
IndexType
OutputImageIndexType
;
typedef
typename
InputImageType
::
IndexType
InputImageIndexType
;
typedef
typename
OutputImageType
::
SizeType
OutputImageSizeType
;
typedef
typename
InputImageType
::
SizeType
InputImageSizeType
;
/** Selectionne le canal a traiter */
itkSetMacro
(
Channel
,
unsigned
int
);
itkGetConstMacro
(
Channel
,
unsigned
int
);
/** ImageDimension enumeration */
itkStaticConstMacro
(
InputImageDimension
,
unsigned
int
,
InputImageType
::
ImageDimension
);
itkStaticConstMacro
(
OutputImageDimension
,
unsigned
int
,
OutputImageType
::
ImageDimension
);
protected:
ImageOfVectorsToMonoChannelExtractROI
();
~
ImageOfVectorsToMonoChannelExtractROI
()
{};
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
/** ExtractImageFilter can produce an image which is a different
* resolution than its input image. As such, ExtractImageFilter
* needs to provide an implementation for
* GenerateOutputInformation() in order to inform the pipeline
* execution model. The original documentation of this method is
* below.
*
* \sa ProcessObject::GenerateOutputInformaton() */
virtual
void
GenerateOutputInformation
();
/** ExtractImageFilter can be implemented as a multithreaded filter.
* \sa ImageToImageFilter::ThreadedGenerateData(),
* ImageToImageFilter::GenerateData() */
void
ThreadedGenerateData
(
const
OutputImageRegionType
&
outputRegionForThread
,
int
threadId
);
private
:
ImageOfVectorsToMonoChannelExtractROI
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
/** Channel to process [1...] */
unsigned
int
m_Channel
;
};
}
// end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include
"otbImageOfVectorsToMonoChannelExtractROI.txx"
#endif
#endif
This diff is collapsed.
Click to expand it.
Code/Common/otbImageOfVectorsToMonoChannelExtractROI.txx
0 → 100644
+
123
−
0
View file @
c8b6a10a
/*=========================================================================
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 __otbMultiToMonoChannelExtractROI_txx
#define __otbMultiToMonoChannelExtractROI_txx
#include "otbMultiToMonoChannelExtractROI.h"
namespace otb
{
/**
*
*/
template<class TInputImage, class TOutputImage>
MultiToMonoChannelExtractROI<TInputImage,TOutputImage>
::MultiToMonoChannelExtractROI() : ExtractROIBase< VectorImage<TInputImage,2> , Image<TOutputImage,2> >(),
m_Channel(1)
{
}
/**
*
*/
template<class TInputImage, class TOutputImage>
void
MultiToMonoChannelExtractROI<TInputImage,TOutputImage>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os,indent);
}
/**
* ExtractImageFilter can produce an image which is a different resolution
* than its input image. As such, ExtractImageFilter needs to provide an
* implementation for GenerateOutputInformation() in order to inform
* the pipeline execution model. The original documentation of this
* method is below.
*
* \sa ProcessObject::GenerateOutputInformaton()
*/
template<class TInputImage, class TOutputImage>
void
MultiToMonoChannelExtractROI<TInputImage,TOutputImage>
::GenerateOutputInformation()
{
typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
// Analyse du canal trait
if ( (m_Channel <= 0) || (m_Channel > InputImagePixelType::Dimension ) )
{
itkExceptionMacro(<< "otb::ExtractImMultiToMonoChannelExtractROIageFilter::GenerateOutputInformation "
<< " Channel must be in the following range: [1;"<< InputImagePixelType::Dimension <<"] "
<< typeid(itk::ImageBase<InputImageDimension>*).name() );
}
// Appel la methode de la classe de base
Superclass::GenerateOutputInformation();
}
template<class TInputImage, class TOutputImage>
void
MultiToMonoChannelExtractROI<TInputImage,TOutputImage>
::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
int threadId)
{
itkDebugMacro(<<"Actually executing");
// Get the input and output pointers
typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
// support progress methods/callbacks
itk::ProgressReporter progress(this, threadId, outputRegionForThread.GetNumberOfPixels());
// Define the portion of the input to walk for this thread
InputImageRegionType inputRegionForThread;
this->CallCopyOutputRegionToInputRegion(inputRegionForThread, outputRegionForThread);
// Define the iterators.
typedef itk::ImageRegionIterator<OutputImageType> OutputIterator;
typedef itk::ImageRegionConstIterator<InputImageType> InputIterator;
OutputIterator outIt(outputPtr, outputRegionForThread);
InputIterator inIt(inputPtr, inputRegionForThread);
// Parcours des canaux a traiter
unsigned int channelIn(m_Channel-1);
InputImagePixelType pixelInput;
while( !outIt.IsAtEnd() )
{
OutputImagePixelType pixelOutput;
pixelInput = inIt.Get();
pixelOutput = static_cast<OutputValueType>(pixelInput[channelIn]);
outIt.Set( pixelOutput );
++outIt;
++inIt;
progress.CompletedPixel();
}
}
} // 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