1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkNeighborhoodSampler.h,v $
Language: C++
Date: $Date: 2009-03-04 15:24:04 $
Version: $Revision: 1.8 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 __itkNeighborhoodSampler_h
#define __itkNeighborhoodSampler_h
#include "itkMacro.h"
#include "itkObject.h"
#include "itkSample.h"
#include "itkSubsample.h"
#include "itkArray.h"
#include "itkSampleAlgorithmBase.h"
namespace itk {
namespace Statistics {
/** \class NeighborhoodSampler
* \brief generates a Subsample that is sampled from the input sample
* using a spherical kernel.
*
* The resulting Subsample has measurement vectors that falls in a
* hyper-sphere that is defined by a center and a radius. To set
* the center, use SetCenter method, and to set radius, use SetRadius
* method. The distance metric is Euclidean one.
*
* <b>Recent API changes:</b>
* The static const macro to get the length of a measurement vector,
* \c MeasurementVectorSize has been removed to allow the length of a measurement
* vector to be specified at run time. Please use the function
* GetMeasurementVectorSize() to get the length. The typedef for \c CenterType
* has changed from FixedArray to Array
*/
template < class TSample >
class ITK_EXPORT NeighborhoodSampler : public SampleAlgorithmBase< TSample >
{
public:
/** Standard class typedefs */
typedef NeighborhoodSampler Self;
typedef SampleAlgorithmBase< TSample > Superclass;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
/** Run-time type information (and related methods) */
itkTypeMacro(NeighborhoodSampler, SampleAlgorithmBase);
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** MeasurementVector typedef support */
typedef TSample SampleType;
/** Enums and typedefs from the TSample */
typedef typename TSample::MeasurementVectorType MeasurementVectorType;
typedef typename TSample::MeasurementType MeasurementType;
typedef typename TSample::FrequencyType FrequencyType;
typedef typename TSample::InstanceIdentifier InstanceIdentifier;
/** typedefs from the superclass */
typedef typename Superclass::InputSampleType InputSampleType;
/** Type of the output subsample object */
typedef Subsample< TSample > SubsampleType;
/** Type of the array of the radii */
typedef double RadiusType;
/** Type of the array of the radii */
typedef Array< double > CenterType;
/** Sets the center of the spherical kernel */
void SetCenter(CenterType* center)
{
if( this->GetMeasurementVectorSize() &&
( center->Size() != this->GetMeasurementVectorSize() ) )
{
itkExceptionMacro( << "Size of measurement vectors in the sample is: " <<
this->GetMeasurementVectorSize() << " but size of center is: " <<
center->Size() );
}
if ( m_Center != center )
{
m_Center = center;
this->Modified();
}
}
/** Gets the center */
CenterType* GetCenter()
{ return m_Center; }
/** Sets the radius of the kernel */
void SetRadius(RadiusType* radius)
{
if ( m_Radius != radius )
{
m_Radius = radius;
this->Modified();
}
}
/** Gets the radius */
RadiusType* GetRadius()
{ return m_Radius; }
/** Output of this algorithm */
typedef SubsampleType OutputType;
/** Output of this algorithm */
typedef typename SubsampleType::Pointer OutputPointer;
/** Gets the Subsample */
OutputPointer GetOutput();
protected:
NeighborhoodSampler();
virtual ~NeighborhoodSampler() {}
virtual void PrintSelf(std::ostream& os, Indent indent) const;
void GenerateData();
private:
NeighborhoodSampler(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
CenterType* m_Center;
RadiusType* m_Radius;
typename SubsampleType::Pointer m_Subsample;
}; // end of class
} // end of namespace Statistics
} // end of namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkNeighborhoodSampler.txx"
#endif
#endif
|