|
| 1 | +/*========================================================================= |
| 2 | + * |
| 3 | + * Copyright Insight Software Consortium |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0.txt |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + * |
| 17 | + *=========================================================================*/ |
| 18 | +#ifndef itkFirstOrderTextureFeaturesImageFilter_h |
| 19 | +#define itkFirstOrderTextureFeaturesImageFilter_h |
| 20 | + |
| 21 | +#include "itkMovingHistogramImageFilter.h" |
| 22 | +#include "itkFirstOrderTextureHistogram.h" |
| 23 | + |
| 24 | +namespace itk |
| 25 | +{ |
| 26 | +/** |
| 27 | + * \class FirstOrderTextureFeaturesImageFilter |
| 28 | + * \brief Compute first order statistics in a neighborhood for each |
| 29 | + * pixel. |
| 30 | + * |
| 31 | + * The output of this filter is a multi-component image where each |
| 32 | + * pixel is: |
| 33 | + * -# mean |
| 34 | + * -# minimum |
| 35 | + * -# maximum |
| 36 | + * -# variance |
| 37 | + * -# standard deviation (sigma) |
| 38 | + * -# skewness |
| 39 | + * -# kurtosis |
| 40 | + * -# entropy. |
| 41 | + * These first order statistics are computed based on a define |
| 42 | + * neighborhood or kernel such as FlatStructuringElement::Box. |
| 43 | + * |
| 44 | + * The boundary is handle by only considering the pixel in the image, |
| 45 | + * so that the boundary pixel have lets data to compute the |
| 46 | + * statistics. |
| 47 | + * |
| 48 | + * \ingroup ITKTextureFeatures |
| 49 | + */ |
| 50 | + |
| 51 | +template< class TInputImage, class TOutputImage, class TKernel > |
| 52 | +class ITK_TEMPLATE_EXPORT FirstOrderTextureFeaturesImageFilter: |
| 53 | + public MovingHistogramImageFilter< TInputImage, |
| 54 | + TOutputImage, |
| 55 | + TKernel, |
| 56 | + typename Function::FirstOrderTextureHistogram< typename TInputImage::PixelType, |
| 57 | + typename TOutputImage::PixelType > > |
| 58 | +{ |
| 59 | +public: |
| 60 | + /** Standard class typedefs. */ |
| 61 | + typedef FirstOrderTextureFeaturesImageFilter Self; |
| 62 | + typedef MovingHistogramImageFilter< TInputImage, TOutputImage, TKernel, |
| 63 | + typename Function::FirstOrderTextureHistogram< typename TInputImage::PixelType, typename TOutputImage::PixelType> > Superclass; |
| 64 | + typedef SmartPointer< Self > Pointer; |
| 65 | + typedef SmartPointer< const Self > ConstPointer; |
| 66 | + |
| 67 | + /** Standard New method. */ |
| 68 | + itkNewMacro(Self); |
| 69 | + |
| 70 | + /** Runtime information support. */ |
| 71 | + itkTypeMacro(FirstOrderTextureFeaturesImageFilter, |
| 72 | + MovingHistogramMorphologyImageFilter); |
| 73 | + |
| 74 | + /** Image related typedefs. */ |
| 75 | + typedef TInputImage InputImageType; |
| 76 | + typedef TOutputImage OutputImageType; |
| 77 | + typedef typename TInputImage::RegionType RegionType; |
| 78 | + typedef typename TInputImage::SizeType SizeType; |
| 79 | + typedef typename TInputImage::IndexType IndexType; |
| 80 | + typedef typename TInputImage::PixelType PixelType; |
| 81 | + typedef typename TInputImage::OffsetType OffsetType; |
| 82 | + typedef typename Superclass::OutputImageRegionType OutputImageRegionType; |
| 83 | + typedef typename TOutputImage::PixelType OutputPixelType; |
| 84 | + |
| 85 | + /** Image related typedefs. */ |
| 86 | + itkStaticConstMacro(ImageDimension, unsigned int, |
| 87 | + TInputImage::ImageDimension); |
| 88 | +protected: |
| 89 | + |
| 90 | + unsigned int GetNumberOfOutputComponents() { return 8;} |
| 91 | + |
| 92 | + FirstOrderTextureFeaturesImageFilter() |
| 93 | + { |
| 94 | + } |
| 95 | + |
| 96 | + void GenerateOutputInformation() |
| 97 | + { |
| 98 | + // this methods is overloaded so that if the output image is a |
| 99 | + // VectorImage then the correct number of components are set. |
| 100 | + |
| 101 | + Superclass::GenerateOutputInformation(); |
| 102 | + OutputImageType* output = this->GetOutput(); |
| 103 | + |
| 104 | + if ( !output ) |
| 105 | + { |
| 106 | + return; |
| 107 | + } |
| 108 | + if ( output->GetNumberOfComponentsPerPixel() != this->GetNumberOfOutputComponents() ) |
| 109 | + { |
| 110 | + output->SetNumberOfComponentsPerPixel( this->GetNumberOfOutputComponents() ); |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + |
| 115 | + ~FirstOrderTextureFeaturesImageFilter() {} |
| 116 | +private: |
| 117 | + FirstOrderTextureFeaturesImageFilter(const Self &); //purposely not implemented |
| 118 | + void operator=(const Self &); //purposely not implemented |
| 119 | +}; // end of class |
| 120 | +} // end namespace itk |
| 121 | + |
| 122 | +#endif |
0 commit comments