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
|
/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkImageToCooccurrenceListAdaptor.h,v $
Language: C++
Date: $Date: 2009-03-04 15:23:50 $
Version: $Revision: 1.7 $
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 __itkImageToCooccurrenceListAdaptor_h
#define __itkImageToCooccurrenceListAdaptor_h
#include <typeinfo>
#include "itkImage.h"
#include "itkPixelTraits.h"
#include "itkImageToListAdaptor.h"
#include "itkSmartPointer.h"
#include "itkImageRegionIterator.h"
#include "itkShapedNeighborhoodIterator.h"
#include "itkNeighborhoodIterator.h"
#include "itkNeighborhoodAlgorithm.h"
#include "itkConstantBoundaryCondition.h"
#include "itkListSample.h"
#include "itkFixedArray.h"
#include "itkMacro.h"
#include <vector>
#include <algorithm>
#include <iostream>
namespace itk {
namespace Statistics {
/** \class ImageToCooccurrenceListAdaptor
* \brief Converts pixel data into a list of pairs in order to compute a cooccurrence Histogram.
*
* This class is intended to be used in combination with the ListToHistogramGenerator class.
*
* \author Glenn Pierce
*
* \ingroup Statistics
*/
template < class TImage >
class ITK_EXPORT ImageToCooccurrenceListAdaptor
: public ImageToListAdaptor<
TImage,
FixedArray< typename TImage::PixelType, 2 > >
{
public:
typedef TImage ImageType;
typedef FixedArray< typename TImage::PixelType, 2 > MeasurementVectorType;
typedef itk::Statistics::ListSample< MeasurementVectorType > SampleType;
typedef typename SampleType::MeasurementVectorSizeType MeasurementVectorSizeType;
/** Standard class typedefs */
typedef ImageToCooccurrenceListAdaptor Self;
typedef ImageToListAdaptor< TImage, MeasurementVectorType > Superclass;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Neighborhood iterator type. */
typedef itk::ShapedNeighborhoodIterator<
TImage ,
ConstantBoundaryCondition<TImage>
> ShapedNeighborhoodIteratorType;
/** Offset type used for Neighborhoods */
typedef typename ShapedNeighborhoodIteratorType::OffsetType OffsetType;
typedef std::vector<OffsetType> OffsetTable;
void UseNeighbor(const OffsetType & offset);
/** Triggers the Computation of the co-occurence matrix */
void Compute();
/** Run-time type information (and related methods). */
itkTypeMacro(ImageToCooccurrenceListAdaptor, ListSampleBase);
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** the number of components in a measurement vector */
itkStaticConstMacro(MeasurementVectorSize, unsigned int, 2);
virtual void SetMeasurementVectorSize( const MeasurementVectorSizeType )
{
// Measurement vector size for this class is fixed as the pixel's
// dimension. This method should have no effect
itkWarningMacro( << "This method does nothing! The MeasurementVectorSize is "
<< MeasurementVectorSize );
}
unsigned int GetMeasurementVectorSize() const
{
return Superclass::MeasurementVectorSize;
}
/** Superclass typedefs for Measurement vector, measurement,
* Instance Identifier, frequency, size, size element value */
typedef typename Superclass::PixelType PixelType;
typedef typename Superclass::FrequencyType FrequencyType;
typedef typename Superclass::MeasurementType MeasurementType;
typedef typename Superclass::InstanceIdentifier InstanceIdentifier;
typedef MeasurementVectorType ValueType;
/** Image dimension. */
itkStaticConstMacro(ImageDimension, unsigned int,
TImage::ImageDimension);
protected:
ImageToCooccurrenceListAdaptor();
virtual ~ImageToCooccurrenceListAdaptor() {}
void PrintSelf(std::ostream& os, Indent indent) const;
private:
ImageToCooccurrenceListAdaptor(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
OffsetTable m_OffsetTable;
typename SampleType::Pointer m_Sample;
}; // end of class ScalarImageToListAdaptor
} // end of namespace Statistics
} // end of namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkImageToCooccurrenceListAdaptor.txx"
#endif
#endif
|