Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed May 15, 2020
2 parents 60ae2b1 + 1661bf0 commit 27258ef
Show file tree
Hide file tree
Showing 280 changed files with 6,250 additions and 5,040 deletions.
2 changes: 1 addition & 1 deletion Examples/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
## The following line uses shorter lines in documentation code
ColumnLimit: 88
ColumnLimit: 78
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Expand Down
26 changes: 13 additions & 13 deletions Examples/DataRepresentation/Image/Image1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ main(int, char *[])
// the image.
//
// In ITK, manually creating an image requires that the image is
// instantiated as previously shown, and that regions describing the image are
// then associated with it.
// instantiated as previously shown, and that regions describing the image
// are then associated with it.
//
// A region is defined by two classes: the \doxygen{Index} and
// \doxygen{Size} classes. The origin of the region within the
// image is defined by the \code{Index}. The extent, or size, of the region
// is defined by the \code{Size}. When an image is created manually, the user
// is responsible for defining the image size and the index at which the
// image grid starts. These two parameters make it possible to process
// is defined by the \code{Size}. When an image is created manually, the
// user is responsible for defining the image size and the index at which
// the image grid starts. These two parameters make it possible to process
// selected regions.
//
// The \code{Index} is represented by a n-dimensional array where each
Expand Down Expand Up @@ -151,14 +151,14 @@ main(int, char *[])

// Software Guide : BeginLatex
//
// Finally, the region is passed to the \code{Image} object in order to define its
// extent and origin. The \code{SetRegions} method sets the
// \emph{LargestPossibleRegion}, \emph{BufferedRegion}, and \emph{RequestedRegion}
// simultaneously. Note that none of the operations performed to this point
// have allocated memory for the image pixel data. It is necessary to
// invoke the \code{Allocate()} method to do this. Allocate does not
// require any arguments since all the information needed for memory
// allocation has already been provided by the region.
// Finally, the region is passed to the \code{Image} object in order to
// define its extent and origin. The \code{SetRegions} method sets the
// \emph{LargestPossibleRegion}, \emph{BufferedRegion}, and
// \emph{RequestedRegion} simultaneously. Note that none of the operations
// performed to this point have allocated memory for the image pixel data.
// It is necessary to invoke the \code{Allocate()} method to do this.
// Allocate does not require any arguments since all the information needed
// for memory allocation has already been provided by the region.
//
// \index{itk::Image!Allocate()}
// \index{itk::Image!SetRegions()}
Expand Down
26 changes: 16 additions & 10 deletions Examples/DataRepresentation/Image/Image3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ main(int, char *[])
ImageType::Pointer image = ImageType::New();

// The image region should be initialized
const ImageType::SizeType size = { { 200, 200, 200 } }; // Size along {X,Y,Z}
const ImageType::IndexType start = { { 0, 0, 0 } }; // First index on {X,Y,Z}
const ImageType::SizeType size = {
{ 200, 200, 200 }
}; // Size along {X,Y,Z}
const ImageType::IndexType start = {
{ 0, 0, 0 }
}; // First index on {X,Y,Z}

ImageType::RegionType region;
region.SetSize(size);
Expand All @@ -66,10 +70,10 @@ main(int, char *[])
//
// The following code illustrates the declaration of an index variable and
// the assignment of values to each of its components. Please note that
// no \code{SmartPointer} is used to access the \code{Index}. This is because
// \code{Index} is a lightweight object that is not intended to be shared
// between objects. It is more efficient to produce multiple copies of
// these small objects than to share them using the SmartPointer
// no \code{SmartPointer} is used to access the \code{Index}. This is
// because \code{Index} is a lightweight object that is not intended to be
// shared between objects. It is more efficient to produce multiple copies
// of these small objects than to share them using the SmartPointer
// mechanism.
//
// The following lines declare an instance of the index type and initialize
Expand All @@ -78,7 +82,9 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
const ImageType::IndexType pixelIndex = { { 27, 29, 37 } }; // Position of {X,Y,Z}
const ImageType::IndexType pixelIndex = {
{ 27, 29, 37 }
}; // Position of {X,Y,Z}
// Software Guide : EndCodeSnippet


Expand Down Expand Up @@ -114,9 +120,9 @@ main(int, char *[])
// and not reference semantics. Hence, the method cannot be used to
// modify image data values.
//
// Remember that both \code{SetPixel()} and \code{GetPixel()} are inefficient
// and should only be used for debugging or for supporting interactions like
// querying pixel values by clicking with the mouse.
// Remember that both \code{SetPixel()} and \code{GetPixel()} are
// inefficient and should only be used for debugging or for supporting
// interactions like querying pixel values by clicking with the mouse.
//
// Software Guide : EndLatex

Expand Down
108 changes: 61 additions & 47 deletions Examples/DataRepresentation/Image/Image4.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
// position of the image in space with respect to some world coordinate
// system are extremely important.
//
// Image origin, voxel directions (i.e. orientation), and spacing are fundamental to
// many applications. Registration, for example, is performed in physical coordinates.
// Improperly defined spacing, direction, and origins will result in inconsistent
// results in such processes. Medical images with no spatial information should not be
// used for medical diagnosis, image analysis, feature extraction, assisted radiation
// therapy or image guided surgery. In other words, medical images lacking spatial
// information are not only useless but also hazardous.
// Image origin, voxel directions (i.e. orientation), and spacing are
// fundamental to many applications. Registration, for example, is performed
// in physical coordinates. Improperly defined spacing, direction, and origins
// will result in inconsistent results in such processes. Medical images with
// no spatial information should not be used for medical diagnosis, image
// analysis, feature extraction, assisted radiation therapy or image guided
// surgery. In other words, medical images lacking spatial information are not
// only useless but also hazardous.
//
// \begin{figure} \center
// \includegraphics[width=\textwidth]{ImageOriginAndSpacing}
Expand All @@ -49,10 +50,10 @@
// spacing is measured between the pixel centers and can be different along
// each dimension. The image origin is associated with the coordinates of the
// first pixel in the image.
// For this simplified example, the voxel lattice is perfectly aligned with physical
// space orientation, and the image direction is therefore an identity mapping. If the
// voxel lattice samples were rotated with respect to physical space, then the image
// direction would contain a rotation matrix.
// For this simplified example, the voxel lattice is perfectly aligned with
// physical space orientation, and the image direction is therefore an
// identity mapping. If the voxel lattice samples were rotated with respect to
// physical space, then the image direction would contain a rotation matrix.
//
// A \emph{pixel} is considered to be the
// rectangular region surrounding the pixel center holding the data
Expand Down Expand Up @@ -80,8 +81,12 @@ main(int, char *[])
using ImageType = itk::Image<unsigned short, Dimension>;
ImageType::Pointer image = ImageType::New();

const ImageType::SizeType size = { { 200, 200, 200 } }; // Size along {X,Y,Z}
const ImageType::IndexType start = { { 0, 0, 0 } }; // First index on {X,Y,Z}
const ImageType::SizeType size = {
{ 200, 200, 200 }
}; // Size along {X,Y,Z}
const ImageType::IndexType start = {
{ 0, 0, 0 }
}; // First index on {X,Y,Z}

ImageType::RegionType region;
region.SetSize(size);
Expand All @@ -97,8 +102,8 @@ main(int, char *[])
// the spacing of the image, an array of the corresponding type must be
// created. The elements of the array should then be initialized with the
// spacing between the centers of adjacent pixels. The following code
// illustrates the methods available in the \doxygen{Image} class for dealing
// with spacing and origin.
// illustrates the methods available in the \doxygen{Image} class for
// dealing with spacing and origin.
//
// \index{itk::Image!Spacing}
//
Expand Down Expand Up @@ -131,8 +136,8 @@ main(int, char *[])
// The spacing information can be retrieved from an image by using the
// \code{GetSpacing()} method. This method returns a reference to a
// \code{FixedArray}. The returned object can then be used to read the
// contents of the array. Note the use of the \code{const} keyword to indicate
// that the array will not be modified.
// contents of the array. Note the use of the \code{const} keyword to
// indicate that the array will not be modified.
//
// Software Guide : EndLatex

Expand Down Expand Up @@ -184,25 +189,28 @@ main(int, char *[])
const ImageType::PointType & origin = image->GetOrigin();

std::cout << "Origin = ";
std::cout << origin[0] << ", " << origin[1] << ", " << origin[2] << std::endl;
std::cout << origin[0] << ", " << origin[1] << ", " << origin[2]
<< std::endl;

// Software Guide : EndCodeSnippet

// TODO: This example should really be written for a more complicated direction
// cosine. i.e. As the first index element increases, the 1st physical space
// decreases.
// TODO: This example should really be written for a more complicated
// direction cosine. i.e. As the first index element increases, the 1st
// physical space decreases.

// Software Guide : BeginLatex
//
// The image direction matrix represents the orientation relationships between
// the image samples and physical space coordinate systems. The image direction
// matrix is an orthonormal matrix that describes the possible permutation of image
// index values and the rotational aspects that are needed to properly reconcile image
// index organization with physical space axis. The image directions is a $N x N$
// matrix where $N$ is the dimension of the image. An identity image direction
// indicates that increasing values of the 1st, 2nd, 3rd index element corresponds to
// increasing values of the 1st, 2nd and 3rd physical space axis respectively, and
// that the voxel samples are perfectly aligned with the physical space axis.
// The image direction matrix represents the orientation relationships
// between the image samples and physical space coordinate systems. The
// image direction matrix is an orthonormal matrix that describes the
// possible permutation of image index values and the rotational aspects
// that are needed to properly reconcile image index organization with
// physical space axis. The image directions is a $N x N$ matrix where $N$
// is the dimension of the image. An identity image direction indicates that
// increasing values of the 1st, 2nd, 3rd index element corresponds to
// increasing values of the 1st, 2nd and 3rd physical space axis
// respectively, and that the voxel samples are perfectly aligned with the
// physical space axis.
//
// The following code illustrates the creation and assignment of a variable
// suitable for initializing the image direction with an identity.
Expand Down Expand Up @@ -238,10 +246,11 @@ main(int, char *[])

// Software Guide : BeginLatex
//
// Once the spacing, origin, and direction of the image samples have been initialized,
// the image will correctly map pixel indices to and from physical space coordinates.
// The following code illustrates how a point in physical space can be mapped into an
// image index for the purpose of reading the content of the closest pixel.
// Once the spacing, origin, and direction of the image samples have been
// initialized, the image will correctly map pixel indices to and from
// physical space coordinates. The following code illustrates how a point in
// physical space can be mapped into an image index for the purpose of
// reading the content of the closest pixel.
//
// First, a \doxygen{Point} type must be declared. The point type is
// templated over the type used to represent coordinates and over the
Expand Down Expand Up @@ -307,7 +316,8 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
const bool isInside = image->TransformPhysicalPointToIndex(point, pixelIndex);
const bool isInside =
image->TransformPhysicalPointToIndex(point, pixelIndex);
if (isInside)
{
ImageType::PixelType pixelValue = image->GetPixel(pixelIndex);
Expand All @@ -328,8 +338,8 @@ main(int, char *[])
// Software Guide : BeginLatex
//
// The following example illustrates the mathematical relationships between
// image index locations and its corresponding physical point representation
// for a given Image.
// image index locations and its corresponding physical point
// representation for a given Image.
//
// \index{itk::Image!PhysicalPoint}
// \index{itk::Image!Index}
Expand Down Expand Up @@ -357,8 +367,8 @@ main(int, char *[])
//
// \gdef\NL{\\}
//
// For a given index $\vec{I}$ in 3D, the physical location $\vec{P}$ is calculated
// as following:
// For a given index $\vec{I}$ in 3D, the physical location $\vec{P}$ is
// calculated as following:
//
// \begin{equation}
// \begin{pmatrix}
Expand Down Expand Up @@ -393,11 +403,12 @@ main(int, char *[])
// \end{equation}
// Where:\newline
// $\vec{I}$: image space index.\newline
// $\vec{P}$: resulting physical space position of the image index $\vec{I}$.\newline
// $\vec{P}$: resulting physical space position of the image index
// $\vec{I}$.\newline
// $\vec{O}$: physical space origin of the first image index.\newline
// $\mathcal{D}$: direction cosines matrix (orthonormal). It represents the
// orientation relationship between the image and the physical space coordinate
// system.\newline
// orientation relationship between the image and the physical space
// coordinate system.\newline
// $\vec{S}$: physical spacing between pixels of the same axis.
// \newline
//
Expand Down Expand Up @@ -439,8 +450,9 @@ main(int, char *[])
SpacingMatrix(1, 1) = ImageSpacing[1];
SpacingMatrix(2, 2) = ImageSpacing[2];

const ImageType::DirectionType & ImageDirectionCosines = image->GetDirection();
const ImageType::PointType & ImageOrigin = image->GetOrigin();
const ImageType::DirectionType & ImageDirectionCosines =
image->GetDirection();
const ImageType::PointType & ImageOrigin = image->GetOrigin();

using VectorType = itk::Vector<double, Dimension>;
VectorType LeftEyeIndexVector;
Expand All @@ -455,7 +467,8 @@ main(int, char *[])
std::cout << "===========================================" << std::endl;
std::cout << "Spacing:: " << std::endl << SpacingMatrix << std::endl;
std::cout << "===========================================" << std::endl;
std::cout << "DirectionCosines:: " << std::endl << ImageDirectionCosines << std::endl;
std::cout << "DirectionCosines:: " << std::endl
<< ImageDirectionCosines << std::endl;
std::cout << "===========================================" << std::endl;
std::cout << "Origin:: " << std::endl << ImageOrigin << std::endl;
std::cout << "===========================================" << std::endl;
Expand All @@ -468,9 +481,10 @@ main(int, char *[])
{
std::cout << "===========================================" << std::endl;
std::cout << "Two results are identical as expected!" << std::endl;
std::cout << "The Left Eye from TransformIndexToPhysicalPoint is " << LeftEyePoint
std::cout << "The Left Eye from TransformIndexToPhysicalPoint is "
<< LeftEyePoint << std::endl;
std::cout << "The Left Eye from Math is " << LeftEyePointByHand
<< std::endl;
std::cout << "The Left Eye from Math is " << LeftEyePointByHand << std::endl;
}

return EXIT_SUCCESS;
Expand Down
23 changes: 14 additions & 9 deletions Examples/DataRepresentation/Image/Image5.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,16 @@ main(int argc, char * argv[])

for (unsigned int z = 0; z < size[2]; z++)
{
const double dz = static_cast<double>(z) - static_cast<double>(size[2]) / 2.0;
const double dz =
static_cast<double>(z) - static_cast<double>(size[2]) / 2.0;
for (unsigned int y = 0; y < size[1]; y++)
{
const double dy = static_cast<double>(y) - static_cast<double>(size[1]) / 2.0;
const double dy =
static_cast<double>(y) - static_cast<double>(size[1]) / 2.0;
for (unsigned int x = 0; x < size[0]; x++)
{
const double dx = static_cast<double>(x) - static_cast<double>(size[0]) / 2.0;
const double dx =
static_cast<double>(x) - static_cast<double>(size[0]) / 2.0;
const double d2 = dx * dx + dy * dy + dz * dz;
*it++ = (d2 < radius2) ? 255 : 0;
}
Expand All @@ -203,12 +206,13 @@ main(int argc, char * argv[])
// Software Guide : BeginLatex
//
// The buffer is passed to the \code{ImportImageFilter} with the
// \code{SetImportPointer()} method. Note that the last argument of this method
// specifies who will be responsible for deleting the memory block once it
// is no longer in use. A \code{false} value indicates that the
// \code{SetImportPointer()} method. Note that the last argument of this
// method specifies who will be responsible for deleting the memory block
// once it is no longer in use. A \code{false} value indicates that the
// \code{ImportImageFilter} will not try to delete the buffer when its
// destructor is called. A \code{true} value, on the other hand, will allow the
// filter to delete the memory block upon destruction of the import filter.
// destructor is called. A \code{true} value, on the other hand, will allow
// the filter to delete the memory block upon destruction of the import
// filter.
//
// For the \code{ImportImageFilter} to appropriately delete the
// memory block, the memory must be allocated with the C++
Expand All @@ -230,7 +234,8 @@ main(int argc, char * argv[])
// Software Guide : BeginLatex
//
// Finally, we can connect the output of this filter to a pipeline.
// For simplicity we just use a writer here, but it could be any other filter.
// For simplicity we just use a writer here, but it could be any other
// filter.
//
// Software Guide : EndLatex

Expand Down
10 changes: 6 additions & 4 deletions Examples/DataRepresentation/Image/ImageAdaptor1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
// provide methods \code{Set()} and \code{Get()}, and define the types of
// \code{InternalPixelType} and \code{ExternalPixelType}. The
// \code{InternalPixelType} corresponds to the pixel type of the image to be
// adapted (\code{unsigned char} in this example). The \code{ExternalPixelType}
// corresponds to the pixel type we wish to emulate with the ImageAdaptor
// adapted (\code{unsigned char} in this example). The
// \code{ExternalPixelType} corresponds to the pixel type we wish to emulate
// with the ImageAdaptor
// (\code{float} in this case).
//
// Software Guide : EndLatex
Expand Down Expand Up @@ -173,8 +174,9 @@ main(int argc, char * argv[])

// Software Guide : BeginLatex
//
// Although in this example, we are just performing a simple summation, the key
// concept is that access to pixels is performed as if the pixel is of type
// Although in this example, we are just performing a simple summation, the
// key concept is that access to pixels is performed as if the pixel is of
// type
// \code{float}. Additionally, it should be noted that the adaptor is used
// as if it was an actual image and not as a filter. ImageAdaptors conform
// to the same API as the \doxygen{Image} class.
Expand Down
Loading

0 comments on commit 27258ef

Please sign in to comment.