1 /*========================================================================= 2 * 3 * Copyright Insight Software Consortium 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0.txt 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 *=========================================================================*/ 18 #ifndef itkPeriodicBoundaryCondition_h 19 #define itkPeriodicBoundaryCondition_h 20 #include "itkImageBoundaryCondition.h" 21 22 namespace itk 23 { 24 /** \class PeriodicBoundaryCondition 25 * \brief 26 * A function object that determines values outside of image boundaries 27 * according to periodic (wrap-around) conditions. 28 * 29 * The input to this function object is a neighborhood iterator. This boundary 30 * condition object is designed to be given as a template argument to a 31 * NeighborhoodIterator or any of the NeighborhoodIterator subclasses. 32 * 33 * \ingroup DataRepresentation 34 * \ingroup ImageObjects 35 * \ingroup ITKCommon 36 */ 37 template< typename TInputImage, typename TOutputImage = TInputImage > 38 class ITK_TEMPLATE_EXPORT PeriodicBoundaryCondition: 39 public ImageBoundaryCondition< TInputImage, TOutputImage > 40 { 41 public: 42 /** Standard class type aliases. */ 43 using Self = PeriodicBoundaryCondition; 44 using Superclass = ImageBoundaryCondition< TInputImage, TOutputImage >; 45 46 /** Extract information from the image type. */ 47 using PixelType = typename Superclass::PixelType; 48 using PixelPointerType = typename Superclass::PixelPointerType; 49 using OutputPixelType = typename Superclass::OutputPixelType; 50 using RegionType = typename Superclass::RegionType; 51 using IndexType = typename Superclass::IndexType; 52 using SizeType = typename Superclass::SizeType; 53 using OffsetType = typename Superclass::OffsetType; 54 using NeighborhoodType = typename Superclass::NeighborhoodType; 55 56 using NeighborhoodAccessorFunctorType = typename Superclass::NeighborhoodAccessorFunctorType; 57 58 /** Extract information from the image type. */ 59 static constexpr unsigned int ImageDimension = Superclass::ImageDimension; 60 61 /** Default constructor. */ 62 PeriodicBoundaryCondition() = default; 63 64 /** Runtime information support. */ GetNameOfClass()65 const char * GetNameOfClass() const override 66 { 67 return "itkPeriodicBoundaryCondition"; 68 } 69 70 /** Computes and returns a neighborhood of appropriate values from 71 * neighborhood iterator data.. */ 72 OutputPixelType operator()(const OffsetType & point_index, 73 const OffsetType & boundary_offset, 74 const NeighborhoodType *data) const override; 75 76 /** Computes and returns the appropriate pixel value from 77 * neighborhood iterator data, using the functor. */ 78 OutputPixelType operator()( 79 const OffsetType & point_index, 80 const OffsetType & boundary_offset, 81 const NeighborhoodType *data, 82 const NeighborhoodAccessorFunctorType & neighborhoodAccessorFunctor) const override; 83 84 /** Determines the necessary input region for the output region. 85 * For this boundary condition, the output region is mapped into the 86 * input image index space. If the mapped region crosses an image 87 * boundary in some dimension, then the entire size of the image in 88 * that dimension is requested. For this reason, it is most memory 89 * efficient to request regions that map to regions that do cross 90 * image boundaries. 91 * 92 * \param inputLargestPossibleRegion Largest possible region of the input image. 93 * \param outputRequestedRegion The output requested region. 94 * \return The necessary input region required to determine the 95 * pixel values in the outputRequestedRegion. 96 */ 97 RegionType GetInputRequestedRegion( const RegionType & inputLargestPossibleRegion, 98 const RegionType & outputRequestedRegion ) const override; 99 100 /** Returns a value for a given pixel at an index. If the index is inside the 101 * bounds of the input image, then the pixel value is obtained from 102 * the input image. Otherwise, the pixel at the desired index (modulo 103 * the size of the image) is returned. 104 * 105 * \param index The index of the desired pixel. 106 * \param image The image from which pixel values should be determined. 107 */ 108 OutputPixelType GetPixel( const IndexType & index, const TInputImage * image ) const override; 109 110 }; 111 } // end namespace itk 112 113 #ifndef ITK_MANUAL_INSTANTIATION 114 #include "itkPeriodicBoundaryCondition.hxx" 115 #endif 116 117 #endif 118