/usr/include/ITK-4.5/itkPhasedArray3DSpecialCoordinatesImage.h is in libinsighttoolkit4-dev 4.5.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef __itkPhasedArray3DSpecialCoordinatesImage_h
#define __itkPhasedArray3DSpecialCoordinatesImage_h
#include "itkSpecialCoordinatesImage.h"
#include "itkPoint.h"
#include "vnl/vnl_math.h"
namespace itk
{
/** \class PhasedArray3DSpecialCoordinatesImage
* \brief Templated 3D nonrectilinear-coordinate image class for
* phased-array "range" images.
*
* \verbatim
*
* y-axis <--------------------+
* |\
* / | \
* `~-| \
* / | \
* ele- | \
* / vation | \
* projection | v x-axis
* to y-z plane -> o |
* v z-axis
*
* \endverbatim
*
* In a phased array "range" image, a point in space is represented by
* the angle between its projection onto the x-z plane and the z-axis
* (the azimuth coordinate), the angle between its projection onto the
* y-z plane and the z-axis (the elevation coordinate), and by its
* distance from the origin (the radius). See the diagram above,
* which illustrates elevation.
*
* The equations form performing the conversion from Cartesian coordinates to
* 3D phased array coordinates are as follows:
*
* azimuth = arctan(x/y)
* elevation = arctan(y/z)
* radius = vcl_sqrt(x^2 + y^2 + z^2)
*
* The reversed transforms are:
*
* z = radius / vcl_sqrt(1 + (tan(azimuth))^2 + (tan(elevation))^2 );
* x = z * vcl_tan(azimuth)
* y = z * vcl_tan(elevation)
*
* PhasedArray3DSpecialCoordinatesImages are templated over a pixel
* type and follow the SpecialCoordinatesImage interface. The data in
* an image is arranged in a 1D array as
* [radius-index][elevation-index][azimuth-index] with azimuth-index
* varying most rapidly. The Index type reverses the order so that
* Index[0] = azimuth-index, Index[1] = elevation-index, and Index[2]
* = radius-index.
*
* Azimuth is discretized into m_AzimuthAngularSeparation intervals
* per angular voxel, the most negative azimuth interval containing
* data is then mapped to azimuth-index=0, and the largest azimuth
* interval containing data is then mapped to azimuth-index=( number
* of samples along azimuth axis - 1 ). Elevation is discretized in
* the same manner. This way, the mapping to Cartesian space is
* symmetric about the z axis such that the line defined by
* azimuth/2,elevation/2 = z-axis. Radius is discretized into
* m_RadiusSampleSize units per angular voxel. The smallest range
* interval containing data is then mapped to radius-index=0, such
* that radius = m_FirstSampleDistance + (radius-index *
* m_RadiusSampleSize).
*
* \sa SpecialCoordinatesImage
*
* \ingroup ImageObjects
* \ingroup ITKCommon
*/
template< typename TPixel >
class PhasedArray3DSpecialCoordinatesImage:
public SpecialCoordinatesImage< TPixel, 3 >
{
public:
/** Standard class typedefs */
typedef PhasedArray3DSpecialCoordinatesImage Self;
typedef SpecialCoordinatesImage< TPixel, 3 > Superclass;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
typedef WeakPointer< const Self > ConstWeakPointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(PhasedArray3DSpecialCoordinatesImage, SpecialCoordinatesImage);
/** Pixel typedef support. Used to declare pixel type in filters
* or other operations. */
typedef TPixel PixelType;
/** Typedef alias for PixelType */
typedef TPixel ValueType;
/** Internal Pixel representation. Used to maintain a uniform API
* with Image Adaptors and allow to keep a particular internal
* representation of data while showing a different external
* representation. */
typedef TPixel InternalPixelType;
typedef typename Superclass::IOPixelType IOPixelType;
/** Accessor type that convert data between internal and external
* representations. */
typedef DefaultPixelAccessor< PixelType > AccessorType;
/** Accessor functor to choose between accessors: DefaultPixelAccessor for
* the Image, and DefaultVectorPixelAccessor for the vector image. The
* functor provides a generic API between the two accessors. */
typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
/** Dimension of the image. This constant is used by functions that are
* templated over image type (as opposed to being templated over pixel type
* and dimension) when they need compile time access to the dimension of
* the image. */
itkStaticConstMacro(ImageDimension, unsigned int, 3);
/** Index typedef support. An index is used to access pixel values. */
typedef typename Superclass::IndexType IndexType;
typedef typename Superclass::IndexValueType IndexValueType;
/** Offset typedef support. An offset is used to access pixel values. */
typedef typename Superclass::OffsetType OffsetType;
/** Size typedef support. A size is used to define region bounds. */
typedef typename Superclass::SizeType SizeType;
typedef typename Superclass::SizeValueType SizeValueType;
/** Container used to store pixels in the image. */
typedef ImportImageContainer< SizeValueType, PixelType > PixelContainer;
/** Region typedef support. A region is used to specify a subset of
* an image.
*/
typedef typename Superclass::RegionType RegionType;
/** Spacing typedef support. Spacing holds the "fake" size of a
* pixel, making each pixel look like a 1 unit hyper-cube to filters
* that were designed for normal images and that therefore use
* m_Spacing. The spacing is the geometric distance between image
* samples.
*/
typedef typename Superclass::SpacingType SpacingType;
/** Origin typedef support. The origin is the "fake" geometric
* coordinates of the index (0,0). Also for use w/ filters designed
* for normal images.
*/
typedef typename Superclass::PointType PointType;
/** A pointer to the pixel container. */
typedef typename PixelContainer::Pointer PixelContainerPointer;
typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
/** \brief Get the continuous index from a physical point
*
* Returns true if the resulting index is within the image, false otherwise.
* \sa Transform */
template< typename TCoordRep >
bool TransformPhysicalPointToContinuousIndex(
const Point< TCoordRep, 3 > & point,
ContinuousIndex< TCoordRep, 3 > & index) const
{
RegionType region = this->GetLargestPossibleRegion();
double maxAzimuth = region.GetSize(0) - 1;
double maxElevation = region.GetSize(1) - 1;
// Convert Cartesian coordinates into angular coordinates
TCoordRep azimuth = vcl_atan(point[0] / point[2]);
TCoordRep elevation = vcl_atan(point[1] / point[2]);
TCoordRep radius = vcl_sqrt(point[0] * point[0]
+ point[1] * point[1]
+ point[2] * point[2]);
// Convert the "proper" angular coordinates into index format
index[0] = static_cast< TCoordRep >( ( azimuth / m_AzimuthAngularSeparation )
+ ( maxAzimuth / 2.0 ) );
index[1] = static_cast< TCoordRep >( ( elevation / m_ElevationAngularSeparation )
+ ( maxElevation / 2.0 ) );
index[2] = static_cast< TCoordRep >( ( ( radius - m_FirstSampleDistance )
/ m_RadiusSampleSize ) );
// Now, check to see if the index is within allowed bounds
const bool isInside = region.IsInside(index);
return isInside;
}
/** Get the index (discrete) from a physical point.
* Floating point index results are truncated to integers.
* Returns true if the resulting index is within the image, false otherwise
* \sa Transform */
template< typename TCoordRep >
bool TransformPhysicalPointToIndex(
const Point< TCoordRep, 3 > & point,
IndexType & index) const
{
RegionType region = this->GetLargestPossibleRegion();
double maxAzimuth = region.GetSize(0) - 1;
double maxElevation = region.GetSize(1) - 1;
// Convert Cartesian coordinates into angular coordinates
TCoordRep azimuth = vcl_atan(point[0] / point[2]);
TCoordRep elevation = vcl_atan(point[1] / point[2]);
TCoordRep radius = vcl_sqrt(point[0] * point[0]
+ point[1] * point[1]
+ point[2] * point[2]);
// Convert the "proper" angular coordinates into index format
index[0] = static_cast< IndexValueType >(
( azimuth / m_AzimuthAngularSeparation )
+ ( maxAzimuth / 2.0 ) );
index[1] = static_cast< IndexValueType >(
( elevation / m_ElevationAngularSeparation )
+ ( maxElevation / 2.0 ) );
index[2] = static_cast< IndexValueType >(
( ( radius - m_FirstSampleDistance )
/ m_RadiusSampleSize ) );
// Now, check to see if the index is within allowed bounds
const bool isInside = region.IsInside(index);
return isInside;
}
/** Get a physical point (in the space which
* the origin and spacing information comes from)
* from a continuous index (in the index space)
* \sa Transform */
template< typename TCoordRep >
void TransformContinuousIndexToPhysicalPoint(
const ContinuousIndex< TCoordRep, 3 > & index,
Point< TCoordRep, 3 > & point) const
{
RegionType region = this->GetLargestPossibleRegion();
double maxAzimuth = region.GetSize(0) - 1;
double maxElevation = region.GetSize(1) - 1;
// Convert the index into proper angular coordinates
TCoordRep azimuth = ( index[0] - ( maxAzimuth / 2.0 ) )
* m_AzimuthAngularSeparation;
TCoordRep elevation = ( index[1] - ( maxElevation / 2.0 ) )
* m_ElevationAngularSeparation;
TCoordRep radius = ( index[2] * m_RadiusSampleSize ) + m_FirstSampleDistance;
// Convert the angular coordinates into Cartesian coordinates
TCoordRep tanOfAzimuth = vcl_tan(azimuth);
TCoordRep tanOfElevation = vcl_tan(elevation);
point[2] = static_cast< TCoordRep >( radius
/ vcl_sqrt(1
+ tanOfAzimuth * tanOfAzimuth
+ tanOfElevation * tanOfElevation) );
point[1] = static_cast< TCoordRep >( point[2] * tanOfElevation );
point[0] = static_cast< TCoordRep >( point[2] * tanOfAzimuth );
}
/** Get a physical point (in the space which
* the origin and spacing information comes from)
* from a discrete index (in the index space)
*
* \sa Transform */
template< typename TCoordRep >
void TransformIndexToPhysicalPoint(
const IndexType & index,
Point< TCoordRep, 3 > & point) const
{
RegionType region = this->GetLargestPossibleRegion();
double maxAzimuth = region.GetSize(0) - 1;
double maxElevation = region.GetSize(1) - 1;
// Convert the index into proper angular coordinates
TCoordRep azimuth =
( static_cast< double >( index[0] ) - ( maxAzimuth / 2.0 ) )
* m_AzimuthAngularSeparation;
TCoordRep elevation =
( static_cast< double >( index[1] ) - ( maxElevation / 2.0 ) )
* m_ElevationAngularSeparation;
TCoordRep radius =
( static_cast< double >( index[2] ) * m_RadiusSampleSize )
+ m_FirstSampleDistance;
// Convert the angular coordinates into Cartesian coordinates
TCoordRep tanOfAzimuth = vcl_tan(azimuth);
TCoordRep tanOfElevation = vcl_tan(elevation);
point[2] = static_cast< TCoordRep >(
radius / vcl_sqrt(
1.0 + tanOfAzimuth * tanOfAzimuth + tanOfElevation * tanOfElevation) );
point[1] = static_cast< TCoordRep >( point[2] * tanOfElevation );
point[0] = static_cast< TCoordRep >( point[2] * tanOfAzimuth );
}
/** Set the number of radians between each azimuth unit. */
itkSetMacro(AzimuthAngularSeparation, double);
/** Set the number of radians between each elevation unit. */
itkSetMacro(ElevationAngularSeparation, double);
/** Set the number of cartesian units between each unit along the R . */
itkSetMacro(RadiusSampleSize, double);
/** Set the distance to add to the radius. */
itkSetMacro(FirstSampleDistance, double);
template< typename TCoordRep >
void TransformLocalVectorToPhysicalVector(
FixedArray< TCoordRep, 3 > & ) const
{}
template< typename TCoordRep >
void TransformPhysicalVectorToLocalVector(
const FixedArray< TCoordRep, 3 > & ,
FixedArray< TCoordRep, 3 > & ) const
{}
protected:
PhasedArray3DSpecialCoordinatesImage()
{
m_RadiusSampleSize = 1;
m_AzimuthAngularSeparation = 1 * ( 2.0 * vnl_math::pi / 360.0 ); // 1
// degree
m_ElevationAngularSeparation = 1 * ( 2.0 * vnl_math::pi / 360.0 ); // 1
// degree
m_FirstSampleDistance = 0;
}
virtual ~PhasedArray3DSpecialCoordinatesImage() {}
void PrintSelf(std::ostream & os, Indent indent) const;
private:
PhasedArray3DSpecialCoordinatesImage(const Self &); //purposely not
// implemented
void operator=(const Self &); //purposely not
// implemented
double m_AzimuthAngularSeparation; // in radians
double m_ElevationAngularSeparation; // in radians
double m_RadiusSampleSize;
double m_FirstSampleDistance;
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkPhasedArray3DSpecialCoordinatesImage.hxx"
#endif
#endif
|