1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: RelativePositionPropImageFilter.h,v $
6 Date: $Date: 2010/07/12 06:57:25 $
7 Version: $Revision: 1.2 $
9 Copyright (c) Insight Software Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
18 #ifndef __RelativePositionPropImageFilter_h
19 #define __RelativePositionPropImageFilter_h
21 #include "itkImageToImageFilter.h"
23 #include "itkConceptChecking.h"
24 #include "itkPointSet.h"
25 #include "itkImageRegionConstIteratorWithIndex.h"
26 #include "itkImageRegionIteratorWithIndex.h"
27 #include "itkMinimumImageFilter.h"
33 /** \class RelativePositionPropImageFilter
34 * \brief Compute the fuzzy subset of an image which satisfies some directional relative position.
35 * \author Jamal Atif and Olivier Nempont
37 * This filter computes a fuzzy subset of an image satisfying a particular directionnal relative position from an object (crisp or fuzzy).
41 * This filter takes a crisp or a fuzzy object as input.
42 * In fuzzy case, the values have to be defined between 0 and 1.
44 * The result is a fuzzy subset which values are defined between
45 * 0 if the relation isn't fulfilled in this point to 1 is the relation is
47 * WARNING: the output image type as to be decimal.
51 * The Alpha1 and Alpha2 parameters are used to specify the direction.
52 * Alpha1 is the angle in 'xy' plane from 'x' unit vector.
53 * Alpha2 is used in 3D to specify the angle with 'xy' plane
56 * K is an opening parameter. Higher value enlarge the support of the result.
57 * By default it is fixed at PI/2
60 * Fuzzy Relative Position Between Objects in Image Processing: A Morphological Approach
62 * IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. 21, NO. 7, JULY 1999
64 * This filter is implemented using the propagation algorithm
67 template <class TInputImage, class TOutputImage, class TtNorm=Function::Minimum<
68 typename TOutputImage::PixelType,
69 typename TOutputImage::PixelType,
70 typename TOutputImage::PixelType> >
71 class ITK_EXPORT RelativePositionPropImageFilter :
72 public ImageToImageFilter< TInputImage, TOutputImage >
75 /** Standard class typedefs. */
76 typedef RelativePositionPropImageFilter Self;
77 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
78 typedef SmartPointer<Self> Pointer;
79 typedef SmartPointer<const Self> ConstPointer;
81 /** Extract some information from the image types. Dimensionality
82 * of the two images is assumed to be the same. */
83 typedef typename TOutputImage::PixelType OutputPixelType;
84 typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
85 typedef typename TInputImage::PixelType InputPixelType;
86 typedef typename TInputImage::InternalPixelType InputInternalPixelType;
88 /** Extract some information from the image types. Dimensionality
89 * of the two images is assumed to be the same. */
90 itkStaticConstMacro(ImageDimension, unsigned int,
91 TOutputImage::ImageDimension);
94 typedef typename itk::Image<typename TInputImage::IndexType , ImageDimension>
95 CorrespondanceMapType;
96 typedef float TabulationPixelType;
97 typedef typename itk::Image<TabulationPixelType , ImageDimension> TabulationImageType;
100 /** Image typedef support. */
101 typedef TInputImage InputImageType;
102 typedef TOutputImage OutputImageType;
104 typedef TtNorm TNormType;
106 typedef itk::Vector<double, ImageDimension> VectorType;
109 /** Method for creation through the object factory. */
112 /** Run-time type information (and related methods). */
113 itkTypeMacro(RelativePositionPropImageFilter, ImageToImageFilter);
115 /** The output pixel type must be signed. */
116 itkConceptMacro(SignedOutputPixelType, (Concept::Signed<OutputPixelType>));
118 /** Standard get/set macros for filter parameters. */
121 itkSetMacro(Alpha1, double);
122 itkGetMacro(Alpha1, double);
123 itkSetMacro(Alpha2, double);
124 itkGetMacro(Alpha2, double);
126 itkSetMacro(K1, double);
127 itkGetMacro(K1, double);
128 // itkSetMacro(K2, double);
129 // itkGetMacro(K2, double);
131 itkSetMacro(Radius, double);
132 itkGetMacro(Radius, double);
134 itkSetMacro(VerboseProgress, bool);
135 itkGetMacro(VerboseProgress, bool);
136 itkBooleanMacro(VerboseProgress);
138 itkSetMacro(Fast, bool);
139 itkGetMacro(Fast, bool);
140 itkBooleanMacro(Fast);
142 void computeDirection()
144 if (ImageDimension == 2) {
145 m_DirectionVector[0]=cos(m_Alpha1);
146 m_DirectionVector[1]=sin(m_Alpha1);
149 m_DirectionVector[0]=cos(m_Alpha1)*cos(m_Alpha2);
150 m_DirectionVector[1]=cos(m_Alpha2)*sin(m_Alpha1);
151 m_DirectionVector[2]=sin(m_Alpha2);
156 virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError);
157 void EnlargeOutputRequestedRegion (DataObject * output);
160 RelativePositionPropImageFilter()
164 m_K1 = vcl_acos(-1.0)/2;
168 m_VerboseProgress = false;
170 virtual ~RelativePositionPropImageFilter() {}
171 void PrintSelf(std::ostream& os, Indent indent) const;
173 //void GenerateThreadedData(const typename TOutputImage::RegionType& outputRegionForThread, int threadId);
177 RelativePositionPropImageFilter(const Self&); //purposely not implemented
178 void operator=(const Self&); //purposely not implemented
187 unsigned int m_Radius;
189 bool m_VerboseProgress;
191 VectorType m_DirectionVector;
194 * 2 pass instead of 2^NDimension. Warning this may cause some artifacts
198 //allocation et initialisation de la carte de correspondance
199 typename CorrespondanceMapType::Pointer InitCorrespondanceMap();
201 //compute the tabulation map
202 typename TabulationImageType::Pointer ComputeAngleTabulation();
207 } // end namespace itk
209 #ifndef ITK_MANUAL_INSTANTIATION
210 #include "RelativePositionPropImageFilter.txx"