ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkChangeInformationImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkChangeInformationImageFilter_h
00019 #define __itkChangeInformationImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 #include "itkFixedArray.h"
00023 
00024 namespace itk
00025 {
00048 template< class TInputImage >
00049 class ITK_EXPORT ChangeInformationImageFilter:
00050   public ImageToImageFilter< TInputImage, TInputImage >
00051 {
00052 public:
00054   typedef ChangeInformationImageFilter                   Self;
00055   typedef ImageToImageFilter< TInputImage, TInputImage > Superclass;
00056   typedef SmartPointer< Self >                           Pointer;
00057   typedef SmartPointer< const Self >                     ConstPointer;
00058 
00060   itkNewMacro(Self);
00061 
00062   typedef TInputImage   InputImageType;
00063   typedef TInputImage   OutputImageType;
00064 
00066   typedef typename OutputImageType::RegionType  OutputImageRegionType;
00067   typedef typename InputImageType::RegionType   InputImageRegionType;
00068 
00070   typedef typename InputImageType::Pointer      InputImagePointer;
00071   typedef typename InputImageType::ConstPointer InputImageConstPointer;
00072 
00074   typedef typename OutputImageType::PixelType OutputImagePixelType;
00075   typedef typename InputImageType::PixelType  InputImagePixelType;
00076 
00078   typedef typename OutputImageType::IndexType        OutputImageIndexType;
00079   typedef typename OutputImageType::SizeType         OutputImageSizeType;
00080   typedef typename OutputImageType::OffsetType       OutputImageOffsetType;
00081   typedef typename OutputImageType::DirectionType    OutputImageDirectionType;
00082   typedef typename OutputImageType::OffsetValueType  OutputImageOffsetValueType;
00083   typedef typename InputImageType::IndexType         InputImageIndexType;
00084   typedef typename InputImageType::SizeType          InputImageSizeType;
00085   typedef typename InputImageType::OffsetType        InputImageOffsetType;
00086   typedef typename InputImageType::DirectionType     InputImageDirectionType;
00087 
00089   itkStaticConstMacro(ImageDimension, unsigned int,
00090                       InputImageType::ImageDimension);
00091 
00093   typedef typename InputImageType::SpacingType   SpacingType;
00094   typedef typename InputImageType::PointType     PointType;
00095   typedef typename InputImageType::DirectionType DirectionType;
00096 
00098   itkTypeMacro(ChangeInformationImageFilter, ImageToImageFilter);
00099 
00102   void SetReferenceImage(InputImageType *image)
00103   {
00104     if ( image != m_ReferenceImage )
00105       {
00106       m_ReferenceImage = image;
00107       this->ProcessObject::SetNthInput(1, const_cast< InputImageType *>( image ) );
00108       this->Modified();
00109       }
00110   }
00112 
00113   itkGetObjectMacro(ReferenceImage, TInputImage);
00114 
00115   itkSetMacro(UseReferenceImage, bool);
00116   itkBooleanMacro(UseReferenceImage);
00117   itkGetConstMacro(UseReferenceImage, bool);
00118 
00122   itkSetMacro(OutputSpacing, SpacingType);
00123   itkGetConstReferenceMacro(OutputSpacing, SpacingType);
00125 
00129   itkSetMacro(OutputOrigin, PointType);
00130   itkGetConstReferenceMacro(OutputOrigin, PointType);
00132 
00136   itkSetMacro(OutputDirection, DirectionType);
00137   itkGetConstReferenceMacro(OutputDirection, DirectionType);
00139 
00148   itkSetMacro(OutputOffset, OutputImageOffsetType);
00149   itkGetConstReferenceMacro(OutputOffset, OutputImageOffsetType);
00150   itkSetVectorMacro(OutputOffset, OutputImageOffsetValueType, ImageDimension);
00152 
00154   void ChangeAll()
00155   {
00156     this->ChangeSpacingOn();
00157     this->ChangeOriginOn();
00158     this->ChangeDirectionOn();
00159     this->ChangeRegionOn();
00160   }
00162 
00165   void ChangeNone()
00166   {
00167     this->ChangeSpacingOff();
00168     this->ChangeOriginOff();
00169     this->ChangeDirectionOff();
00170     this->ChangeRegionOff();
00171   }
00173 
00180   itkSetMacro(ChangeSpacing, bool);
00181   itkBooleanMacro(ChangeSpacing);
00182   itkGetConstMacro(ChangeSpacing, bool);
00183 
00190   itkSetMacro(ChangeOrigin, bool);
00191   itkBooleanMacro(ChangeOrigin);
00192   itkGetConstMacro(ChangeOrigin, bool);
00193 
00200   itkSetMacro(ChangeDirection, bool);
00201   itkBooleanMacro(ChangeDirection);
00202   itkGetConstMacro(ChangeDirection, bool);
00203 
00206   itkSetMacro(ChangeRegion, bool);
00207   itkBooleanMacro(ChangeRegion);
00208   itkGetConstMacro(ChangeRegion, bool);
00209 
00213   itkSetMacro(CenterImage, bool);
00214   itkBooleanMacro(CenterImage);
00215   itkGetConstMacro(CenterImage, bool);
00217 
00219   virtual void GenerateOutputInformation();
00220 
00222   virtual void GenerateInputRequestedRegion();
00223 
00225   void GenerateData();
00226 
00227 protected:
00228   ChangeInformationImageFilter();
00229   //~ChangeInformationImageFilter() {} default implementation ok
00230 
00231   void PrintSelf(std::ostream & os, Indent indent) const;
00232 
00238   virtual void VerifyInputInformation() {}
00239 
00240 private:
00241   ChangeInformationImageFilter(const Self &); //purposely not implemented
00242   void operator=(const Self &);               //purposely not implemented
00243 
00244   InputImagePointer m_ReferenceImage;
00245 
00246   bool m_CenterImage;
00247   bool m_ChangeSpacing;
00248   bool m_ChangeOrigin;
00249   bool m_ChangeDirection;
00250   bool m_ChangeRegion;
00251   bool m_UseReferenceImage;
00252 
00253   SpacingType   m_OutputSpacing;
00254   PointType     m_OutputOrigin;
00255   DirectionType m_OutputDirection;
00256 
00257   OutputImageOffsetType m_OutputOffset;
00258   OutputImageOffsetType m_Shift;
00259 };
00260 } // end namespace itk
00261 
00262 #ifndef ITK_MANUAL_INSTANTIATION
00263 #include "itkChangeInformationImageFilter.hxx"
00264 #endif
00265 
00266 #endif
00267