Permute Sequence of Indices#

Synopsis#

Permute a sequence of indices.

Results#

Output:

1 0 4 3 2

After shuffle
4 1 0 2 3

Code#

C++#

#include <itkImageRandomNonRepeatingConstIteratorWithIndex.h>

int
main()
{
  itk::RandomPermutation rp(5);

  std::cout << std::endl;

  for (unsigned int i = 0; i < 5; ++i)
  {
    std::cout << rp[i] << " ";
  }
  std::cout << std::endl << std::endl;

  rp.Shuffle();
  std::cout << "After shuffle" << std::endl;
  for (unsigned int i = 0; i < 5; ++i)
  {
    std::cout << rp[i] << " ";
  }
  std::cout << std::endl;


  return EXIT_SUCCESS;
}

Classes demonstrated#

template<typename TImage>
class ImageRandomNonRepeatingConstIteratorWithIndex : public itk::ImageConstIteratorWithIndex<TImage>

A multi-dimensional image iterator that visits a random set of pixels within an image region. All pixels in the image will be visited before any are repeated. A priority image may be passed to the iterator which will cause it to select certain sets of pixels (those with lower priority values) before others.

This class was contributed by Rupert Brooks, McGill Centre for Intelligent Machines, Montreal, Canada. It is heavily based on the ImageRandomIterator class.

ImageRandomNonRepeatingConstIteratorWithIndex is a multi-dimensional iterator class that is templated over image type. ImageRandomNonRepeatingConstIteratorWithIndex is constrained to walk only within the specified region. When first instantiated, it creates (and stores) a random permutation of the image pixels. It then visits each pixel in the order specified by the permutation. Thus, iterator++ followed by iterator&#8212; will end up leaving the iterator pointing at the same pixel. Furthermore, iterating from beginning to end will cover each pixel in the region exactly once.

This iterator can be passed an image the same size as the region, which specifies a priority for the pixels. Within areas of this priority image that have the same value, the pixel selection will be random. Otherwise the pixel selection will be in the order of the priority image. In the extreme, this allows the order of the pixel selection to be completely specified.

ImageRandomNonRepeatingConstIteratorWithIndex assumes a particular layout of the image data. The is arranged in a 1D array as if it were [][][][slice][row][col] with Index[0] = col, Index[1] = row, Index[2] = slice, etc.

See also

ImageConstIterator

See also

ConditionalConstIterator

See also

ConstNeighborhoodIterator

See also

ConstShapedNeighborhoodIterator

See also

ConstSliceIterator

See also

CorrespondenceDataStructureIterator

See also

FloodFilledFunctionConditionalConstIterator

See also

FloodFilledImageFunctionConditionalConstIterator

See also

FloodFilledImageFunctionConditionalIterator

See also

FloodFilledSpatialFunctionConditionalConstIterator

See also

FloodFilledSpatialFunctionConditionalIterator

See also

ImageConstIterator

See also

ImageConstIteratorWithIndex

See also

ImageIterator

See also

ImageIteratorWithIndex

See also

ImageLinearConstIteratorWithIndex

See also

ImageLinearIteratorWithIndex

See also

ImageRandomNonRepeatingConstIteratorWithIndex

See also

ImageRandomIteratorWithIndex

See also

ImageRegionConstIterator

See also

ImageRegionConstIteratorWithIndex

See also

ImageRegionExclusionConstIteratorWithIndex

See also

ImageRegionExclusionIteratorWithIndex

See also

ImageRegionIterator

See also

ImageRegionIteratorWithIndex

See also

ImageRegionReverseConstIterator

See also

ImageRegionReverseIterator

See also

ImageReverseConstIterator

See also

ImageReverseIterator

See also

ImageSliceConstIteratorWithIndex

See also

ImageSliceIteratorWithIndex

See also

NeighborhoodIterator

See also

PathConstIterator

See also

PathIterator

See also

ShapedNeighborhoodIterator

See also

SliceIterator

See also

ImageConstIteratorWithIndex

MORE INFORMATION

For a complete description of the ITK Image Iterators and their API, please see the Iterators chapter in the ITK Software Guide. The ITK Software Guide is available in print and as a free .pdf download from https://www.itk.org.

Author

Rupert Brooks, McGill Centre for Intelligent Machines. Canada

ITK Sphinx Examples:

Subclassed by itk::ImageRandomNonRepeatingIteratorWithIndex< TImage >

See itk::ImageRandomNonRepeatingConstIteratorWithIndex for additional documentation.