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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
/*=========================================================================
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 otbSFSTexturesImageFilter_h
#define otbSFSTexturesImageFilter_h
#include "otbSFSTexturesFunctor.h"
#include "itkImageToImageFilter.h"
#include "itkImageRegionIteratorWithIndex.h"
#include "itkConstNeighborhoodIterator.h"
namespace otb
{
/** \class SFSTexturesImageFilter
* \brief This functor computes the texture describes in the following publication
* It is based on line direction estimation.
*
* Please refer to Xin Huang, Liangpei Zhang and Pingxiang Li publication,
* Classification and Extraction of Spatial Features in Urban Areas
* Using High-Resolution Multispectral Imagery.
* IEEE Geoscience and Remote Sensing Letters,
* vol. 4, n. 2, 2007, pp 260-264
*
* The texture is computated for each pixel using its neighborhood.
* User can set the spatial threshold that is the max line length, the spectral threshold
* that is the max difference authorized between a pixel of the line and the center pixel
* of the current neighborhood. Alpha and RatioMaxConsideration are used to compute
* the \f$ \omega \f$ - mean value. Finally, The number of direction can be precised with
* NumberOfDirections.
* You can choose the computed textures using SetTextureStatus method (1:length, 2:width,
* 3:PSI, 4:w-mean, 5:ratio, 6:SD).
*
* \sa SFSTexturesFunctor
* \ingroup Textures
*
* \ingroup OTBTextures
*/
template <class TInputImage, class TOutputImage>
class ITK_EXPORT SFSTexturesImageFilter :
public itk::ImageToImageFilter<TInputImage, TOutputImage>
{
public:
/** Standard class typedefs. */
typedef SFSTexturesImageFilter Self;
typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
typedef itk::ImageToImageFilter<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(UnaryFunctorNeighborhoodImageFilter, ImageToImageFilter);
/** Some convenient typedefs. */
typedef typename InputImageType::ConstPointer InputImagePointerType;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename InputImageType::SizeType InputImageSizeType;
typedef typename OutputImageType::Pointer OutputImagePointerType;
typedef typename OutputImageType::RegionType OutputImageRegionType;
typedef typename OutputImageType::PixelType OutputImagePixelType;
typedef itk::ConstNeighborhoodIterator<TInputImage> NeighborhoodIteratorType;
typedef typename NeighborhoodIteratorType::RadiusType RadiusType;
typedef Functor::SFSTexturesFunctor<NeighborhoodIteratorType, OutputImagePixelType> FunctorType;
typedef typename FunctorType::OutputType FunctorOutputType;
typedef itk::ProcessObject ProcessObjectType;
/**Set/Get the radius of neighborhood.*/
itkGetMacro(Radius, unsigned int);
/** Functor accessors */
FunctorType& GetFunctor()
{
return m_Functor;
}
const FunctorType& GetFunctor() const
{
return m_Functor;
}
void SetFunctor(const FunctorType& functor)
{
m_Functor = functor;
this->Modified();
}
/** Spatial Threshold accessor */
void SetSpatialThreshold(unsigned int thresh)
{
this->GetFunctor().SetSpatialThreshold(thresh);
m_Radius = thresh;
this->Modified();
}
unsigned int GetSpatialThreshold()
{
return this->GetFunctor().GetSpatialThreshold();
}
/** Spectral Threshold accessor */
void SetSpectralThreshold(InputImagePixelType thresh)
{
this->GetFunctor().SetSpectralThreshold(thresh);
}
InputImagePixelType GetSpectralThreshold()
{
return this->GetFunctor().GetSpectralThreshold();
}
/** RatioMaxConsiderationNumber accessor */
void SetRatioMaxConsiderationNumber(unsigned int value)
{
this->GetFunctor().SetRatioMaxConsiderationNumber(value);
}
unsigned int GetRatioMaxConsiderationNumber()
{
return this->GetFunctor().GetRatioMaxConsiderationNumber();
}
/** Alpha accessor */
void SetAlpha(double alpha)
{
this->GetFunctor().SetAlpha(alpha);
}
double GetAlpha()
{
return this->GetFunctor().GetAlpha();
}
/** Number Of Directions */
void SetNumberOfDirections(unsigned int D)
{
this->GetFunctor().SetNumberOfDirections(D);
double step = CONST_PI / static_cast<double>(D);
this->GetFunctor().SetDirectionStep(step);
}
unsigned int GetNumberOfDirections()
{
return this->GetFunctor().GetNumberOfDirections();
}
/** Texture selection accessors
* 1: LENGTH
* 2: WIDTH
* 3: PSI
* 4: WMEAN
* 5: RATIO
* 6: SD
* Set to 1 means the texture will be computed.
**/
typedef enum {LENGTH = 1, WIDTH, PSI, WMEAN, RATIO, SD} FeatureType;
void SetFeatureStatus(FeatureType id, bool isSelected)
{
if (static_cast<unsigned int>(id) > this->GetTexturesStatus().size() || id == 0)
{
itkExceptionMacro(
<< "Invalid texture index " << id << ", must be in [1;" << this->GetTexturesStatus().size() << "]");
}
else
{
this->GetFunctor().SetTextureStatus(id - 1, isSelected);
}
}
std::vector<bool> GetTexturesStatus()
{
return this->GetFunctor().GetTexturesStatus();
}
void InitFeatureStatus(bool status);
/** Return output length image */
const OutputImageType * GetLengthOutput() const;
OutputImageType * GetLengthOutput();
/** Return output width image */
const OutputImageType * GetWidthOutput() const;
OutputImageType * GetWidthOutput();
/** Return output PSI image */
const OutputImageType * GetPSIOutput() const;
OutputImageType * GetPSIOutput();
/** Return output WMean image */
const OutputImageType * GetWMeanOutput() const;
OutputImageType * GetWMeanOutput();
/** Return output ratio image */
const OutputImageType * GetRatioOutput() const;
OutputImageType * GetRatioOutput();
/** Return output SD image */
const OutputImageType * GetSDOutput() const;
OutputImageType * GetSDOutput();
void GenerateOutputInformation() ITK_OVERRIDE;
std::vector<FunctorType> m_FunctorList;
protected:
SFSTexturesImageFilter();
~SFSTexturesImageFilter() ITK_OVERRIDE{}
void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
void BeforeThreadedGenerateData() ITK_OVERRIDE;
void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId) ITK_OVERRIDE;
/** Pad the input requested region by radius */
void GenerateInputRequestedRegion(void) ITK_OVERRIDE;
private:
SFSTexturesImageFilter(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
unsigned int m_Radius;
FunctorType m_Functor;
};
} // end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbSFSTexturesImageFilter.txx"
#endif
#endif
|