ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkRandomImageSource.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 /*=========================================================================
00019  *
00020  *  Portions of this file are subject to the VTK Toolkit Version 3 copyright.
00021  *
00022  *  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00023  *
00024  *  For complete copyright, license and disclaimer of warranty information
00025  *  please refer to the NOTICE file at the top of the ITK source tree.
00026  *
00027  *=========================================================================*/
00028 #ifndef __itkRandomImageSource_h
00029 #define __itkRandomImageSource_h
00030 
00031 #include "itkImageSource.h"
00032 #include "itkNumericTraits.h"
00033 
00034 namespace itk
00035 {
00053 template< typename TOutputImage >
00054 class ITK_EXPORT RandomImageSource:public ImageSource< TOutputImage >
00055 {
00056 public:
00058   typedef RandomImageSource           Self;
00059   typedef ImageSource< TOutputImage > Superclass;
00060   typedef SmartPointer< Self >        Pointer;
00061   typedef SmartPointer< const Self >  ConstPointer;
00062 
00064   typedef typename TOutputImage::PixelType OutputImagePixelType;
00065 
00067   typedef typename TOutputImage::RegionType OutputImageRegionType;
00068 
00070   itkTypeMacro(RandomImageSource, ImageSource);
00071 
00073   itkNewMacro(Self);
00074 
00076   typedef typename TOutputImage::SizeType         SizeType;
00077   typedef typename TOutputImage::IndexType        IndexType;
00078   typedef typename TOutputImage::SpacingType      SpacingType;
00079   typedef typename TOutputImage::PointType        PointType;
00080   typedef typename SizeType::SizeValueType        SizeValueType;
00081   typedef SizeValueType                           SizeValueArrayType[TOutputImage::ImageDimension];
00082   typedef typename TOutputImage::SpacingValueType SpacingValueType;
00083   typedef SpacingValueType                        SpacingValueArrayType[TOutputImage::ImageDimension];
00084   typedef typename TOutputImage::PointValueType   PointValueType;
00085   typedef PointValueType                          PointValueArrayType[TOutputImage::ImageDimension];
00086 
00088   itkSetMacro(Size, SizeType);
00089   virtual void SetSize(SizeValueArrayType sizeArray);
00091 
00092   virtual const SizeValueType * GetSize() const;
00093 
00095   itkSetMacro(Spacing, SpacingType);
00096   virtual void SetSpacing(SpacingValueArrayType spacingArray);
00098 
00099   virtual const SpacingValueType * GetSpacing() const;
00100 
00102   itkSetMacro(Origin, PointType);
00103   virtual void SetOrigin(PointValueArrayType originArray);
00105 
00106   virtual const PointValueType * GetOrigin() const;
00107 
00110   itkSetClampMacro( Min, OutputImagePixelType,
00111                     NumericTraits< OutputImagePixelType >::NonpositiveMin(),
00112                     NumericTraits< OutputImagePixelType >::max() );
00113 
00115   itkGetConstMacro(Min, OutputImagePixelType);
00116 
00119   itkSetClampMacro( Max, OutputImagePixelType,
00120                     NumericTraits< OutputImagePixelType >::NonpositiveMin(),
00121                     NumericTraits< OutputImagePixelType >::max() );
00122 
00124   itkGetConstMacro(Max, OutputImagePixelType);
00125 protected:
00126   RandomImageSource();
00127   ~RandomImageSource();
00128   void PrintSelf(std::ostream & os, Indent indent) const;
00130 
00131   virtual void
00132   ThreadedGenerateData(const OutputImageRegionType &
00133                        outputRegionForThread, ThreadIdType threadId);
00134 
00135   virtual void GenerateOutputInformation();
00136 
00137 private:
00138   RandomImageSource(const RandomImageSource &); //purposely not implemented
00139   void operator=(const RandomImageSource &);    //purposely not implemented
00140 
00141   SizeType    m_Size;       //size of the output image
00142   SpacingType m_Spacing;    //spacing
00143   PointType   m_Origin;     //origin
00144 
00145   typename TOutputImage::PixelType m_Min; //minimum possible value
00146   typename TOutputImage::PixelType m_Max; //maximum possible value
00147 
00148   // The following variables are deprecated, and provided here just for
00149   // backward compatibility. It use is discouraged.
00150   mutable PointValueArrayType   m_OriginArray;
00151   mutable SpacingValueArrayType m_SpacingArray;
00152 };
00153 } // end namespace itk
00154 
00155 #ifndef ITK_MANUAL_INSTANTIATION
00156 #include "itkRandomImageSource.hxx"
00157 #endif
00158 
00159 #endif
00160