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 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.
- 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
- See
ImageConstIterator
- See
ConditionalConstIterator
- See
ConstNeighborhoodIterator
- See
ConstShapedNeighborhoodIterator
- See
ConstSliceIterator
- See
CorrespondenceDataStructureIterator
- See
FloodFilledFunctionConditionalConstIterator
- See
FloodFilledImageFunctionConditionalConstIterator
- See
FloodFilledImageFunctionConditionalIterator
- See
FloodFilledSpatialFunctionConditionalConstIterator
- See
FloodFilledSpatialFunctionConditionalIterator
- See
ImageConstIterator
- See
ImageConstIteratorWithIndex
- See
ImageIterator
- See
ImageIteratorWithIndex
- See
ImageLinearConstIteratorWithIndex
- See
ImageLinearIteratorWithIndex
- See
ImageRandomNonRepeatingConstIteratorWithIndex
- See
ImageRandomIteratorWithIndex
- See
ImageRegionConstIterator
- See
ImageRegionConstIteratorWithIndex
- See
ImageRegionExclusionConstIteratorWithIndex
- See
ImageRegionExclusionIteratorWithIndex
- See
ImageRegionIterator
- See
ImageRegionIteratorWithIndex
- See
ImageRegionReverseConstIterator
- See
ImageRegionReverseIterator
- See
ImageReverseConstIterator
- See
ImageReverseIterator
- See
ImageSliceConstIteratorWithIndex
- See
ImageSliceIteratorWithIndex
- See
NeighborhoodIterator
- See
PathConstIterator
- See
PathIterator
- See
ShapedNeighborhoodIterator
- See
SliceIterator
- See
ImageConstIteratorWithIndex
- ITK Sphinx Examples:
Subclassed by itk::ImageRandomNonRepeatingIteratorWithIndex< TImage >