Create A Size

Synopsis

Create a itk::Size, which represents the size of a region in an itk::Image.

Results

Output::

[0, 0] [1, 2]

Code

C++

#include "itkSize.h"

int
main(int, char *[])
{
  constexpr unsigned int Dimension = 2;
  itk::Size<Dimension>   size;

  // Method 1
  // set both components (size[0] and size[1]) to the same value
  // (in this case, 0).
  size.Fill(0);
  std::cout << size << std::endl;

  // Method 2
  // set each component separately.
  size[0] = 1;
  size[1] = 2;

  std::cout << size << std::endl;

  return EXIT_SUCCESS;
}

Python

#!/usr/bin/env python

Dimension = 2

size = itk.Size[Dimension]()

# Method 1
#
# Set both components (size[0] and size[1]) to the same value
# (in this case, 0).
size.Fill(0)
print(size)

# Method 2
#
# Set each component separately.
size[0] = 1
size[1] = 2
print(size)

Classes demonstrated