Compute Texture Features


Wish List Still needs additional work to finish proper creation of example.


Compute texture features.



Help Wanted Implementation of Results for sphinx examples containing this message. Reconfiguration of CMakeList.txt may be necessary. Write An Example <>



#include "itkImage.h"
#include "itkRandomImageSource.h"
#include "itkScalarImageToTextureFeaturesFilter.h"

using ImageType = itk::Image<float, 2>;

static void CreateImage(ImageType::Pointer);

main(int, char *[])
  ImageType::Pointer image = ImageType::New();

  using TextureFilterType = itk::Statistics::ScalarImageToTextureFeaturesFilter<ImageType>;
  TextureFilterType::Pointer textureFilter = TextureFilterType::New();

  const TextureFilterType::FeatureValueVector * output = textureFilter->GetFeatureMeans();
  for (unsigned int i = 0; i < output->size(); ++i)
    std::cout << (*output)[i] << std::endl;

  return EXIT_SUCCESS;

static void
CreateImage(ImageType::Pointer image)
  itk::Index<2> index;

  itk::Size<2> size;

  itk::ImageRegion<2> region(index, size);

Classes demonstrated

template<typename TImageType, typename THistogramFrequencyContainer = DenseFrequencyContainer2>
class ScalarImageToTextureFeaturesFilter : public itk::ProcessObject

This class computes texture descriptions from an image.

This class computes features that summarize the texture of a given image. The texture features are computed a la Haralick, and have proven to be useful in image classification for biological and medical imaging. This class computes the texture features of an image (optionally in a masked region), averaged across several spatial directions so that they are invariant to rotation.

By default, texture features are computed for each spatial direction and then averaged afterward, so it is possible to access the standard deviations of the texture features. These values give a clue as to texture anisotropy. However, doing this is much more work, because it involved computing one GLCM for each offset given. To compute a single GLCM using the first offset , call FastCalculationsOn(). If this is called, then the texture standard deviations will not be computed (and will be set to zero), but texture computation will be much faster.

This class is templated over the input image type.

Template Parameters: The image type, and the type of histogram frequency container. If you are using a large number of bins per axis, a sparse frequency container may be advisable. The default is to use a dense frequency container.

Inputs and parameters:

  1. An image

  2. A mask defining the region over which texture features will be calculated. (Optional)

  3. The pixel value that defines the “inside” of the mask. (Optional, defaults to 1 if a mask is set.)

  4. The set of features to be calculated. These features are defined in the GreyLevelCooccurrenceMatrixTextureCoefficientsCalculator class. (Optional, defaults to {Energy, Entropy, InverseDifferenceMoment, Inertia, ClusterShade, ClusterProminence}, as in Conners, Trivedi and Harlow.)

  5. The number of intensity bins. (Optional, defaults to 256.)

  6. The set of directions (offsets) to average across. (Optional, defaults to {(-1, 0), (-1, -1), (0, -1), (1, -1)} for 2D images and scales analogously for ND images.)

  7. The pixel intensity range over which the features will be calculated. (Optional, defaults to the full dynamic range of the pixel type.)

In general, the default parameter values should be sufficient.

Outputs: (1) The average value of each feature. (2) The standard deviation in the values of each feature.

Web reference:

Print references: Haralick, R.M., K. Shanmugam and I. Dinstein. 1973. Textural Features for Image Classification. IEEE Transactions on Systems, Man and Cybernetics. SMC-3(6):610-620.

Haralick, R.M. 1979. Statistical and Structural Approaches to Texture. Proceedings of the IEEE, 67:786-804.

R.W. Conners and C.A. Harlow. A Theoretical Comaprison of Texture Algorithms. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2:204-222, 1980.

R.W. Conners, M.M. Trivedi, and C.A. Harlow. Segmentation of a High-Resolution Urban Scene using Texture Operators. Computer Vision, Graphics and Image Processing, 25:273-310, 1984.

Author: Zachary Pincus





ITK Sphinx Examples:

See itk::Statistics::ScalarImageToTextureFeaturesFilter for additional documentation.