1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================*/
18 /*=========================================================================
20 Program: Insight Segmentation & Registration Toolkit
21 Module: $RCSfile: RelativePositionPropImageFilter.h,v $
23 Date: $Date: 2010/07/12 06:57:25 $
24 Version: $Revision: 1.2 $
26 Copyright (c) Insight Software Consortium. All rights reserved.
27 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
29 This software is distributed WITHOUT ANY WARRANTY; without even
30 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31 PURPOSE. See the above copyright notices for more information.
33 =========================================================================*/
35 #ifndef __RelativePositionPropImageFilter_h
36 #define __RelativePositionPropImageFilter_h
38 #include "itkImageToImageFilter.h"
40 #include "itkConceptChecking.h"
41 #include "itkPointSet.h"
42 #include "itkImageRegionConstIteratorWithIndex.h"
43 #include "itkImageRegionIteratorWithIndex.h"
44 #include "itkMinimumImageFilter.h"
50 /** \class RelativePositionPropImageFilter
51 * \brief Compute the fuzzy subset of an image which satisfies some directional relative position.
52 * \author Jamal Atif and Olivier Nempont
54 * This filter computes a fuzzy subset of an image satisfying a particular directionnal relative position from an object (crisp or fuzzy).
58 * This filter takes a crisp or a fuzzy object as input.
59 * In fuzzy case, the values have to be defined between 0 and 1.
61 * The result is a fuzzy subset which values are defined between
62 * 0 if the relation isn't fulfilled in this point to 1 is the relation is
64 * WARNING: the output image type as to be decimal.
68 * The Alpha1 and Alpha2 parameters are used to specify the direction.
69 * Alpha1 is the angle in 'xy' plane from 'x' unit vector.
70 * Alpha2 is used in 3D to specify the angle with 'xy' plane
73 * K is an opening parameter. Higher value enlarge the support of the result.
74 * By default it is fixed at PI/2
77 * Fuzzy Relative Position Between Objects in Image Processing: A Morphological Approach
79 * IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. 21, NO. 7, JULY 1999
81 * This filter is implemented using the propagation algorithm
84 template <class TInputImage, class TOutputImage, class TtNorm=Function::Minimum<
85 typename TOutputImage::PixelType,
86 typename TOutputImage::PixelType,
87 typename TOutputImage::PixelType> >
88 class ITK_EXPORT RelativePositionPropImageFilter :
89 public ImageToImageFilter< TInputImage, TOutputImage >
92 /** Standard class typedefs. */
93 typedef RelativePositionPropImageFilter Self;
94 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
95 typedef SmartPointer<Self> Pointer;
96 typedef SmartPointer<const Self> ConstPointer;
98 /** Extract some information from the image types. Dimensionality
99 * of the two images is assumed to be the same. */
100 typedef typename TOutputImage::PixelType OutputPixelType;
101 typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
102 typedef typename TInputImage::PixelType InputPixelType;
103 typedef typename TInputImage::InternalPixelType InputInternalPixelType;
105 /** Extract some information from the image types. Dimensionality
106 * of the two images is assumed to be the same. */
107 itkStaticConstMacro(ImageDimension, unsigned int,
108 TOutputImage::ImageDimension);
111 typedef typename itk::Image<typename TInputImage::IndexType , ImageDimension>
112 CorrespondanceMapType;
113 typedef float TabulationPixelType;
114 typedef typename itk::Image<TabulationPixelType , ImageDimension> TabulationImageType;
117 /** Image typedef support. */
118 typedef TInputImage InputImageType;
119 typedef TOutputImage OutputImageType;
121 typedef TtNorm TNormType;
123 typedef itk::Vector<double, ImageDimension> VectorType;
126 /** Method for creation through the object factory. */
129 /** Run-time type information (and related methods). */
130 itkTypeMacro(RelativePositionPropImageFilter, ImageToImageFilter);
132 /** The output pixel type must be signed. */
133 itkConceptMacro(SignedOutputPixelType, (Concept::Signed<OutputPixelType>));
135 /** Standard get/set macros for filter parameters. */
138 itkSetMacro(Alpha1, double);
139 itkGetMacro(Alpha1, double);
140 itkSetMacro(Alpha2, double);
141 itkGetMacro(Alpha2, double);
143 itkSetMacro(K1, double);
144 itkGetMacro(K1, double);
145 // itkSetMacro(K2, double);
146 // itkGetMacro(K2, double);
148 itkSetMacro(Radius, double);
149 itkGetMacro(Radius, double);
151 itkSetMacro(VerboseProgress, bool);
152 itkGetMacro(VerboseProgress, bool);
153 itkBooleanMacro(VerboseProgress);
155 itkSetMacro(Fast, bool);
156 itkGetMacro(Fast, bool);
157 itkBooleanMacro(Fast);
159 void computeDirection()
161 if (ImageDimension == 2) {
162 m_DirectionVector[0]=cos(m_Alpha1);
163 m_DirectionVector[1]=sin(m_Alpha1);
166 m_DirectionVector[0]=cos(m_Alpha1)*cos(m_Alpha2);
167 m_DirectionVector[1]=cos(m_Alpha2)*sin(m_Alpha1);
168 m_DirectionVector[2]=sin(m_Alpha2);
173 virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError);
174 void EnlargeOutputRequestedRegion (DataObject * output);
177 RelativePositionPropImageFilter()
181 m_K1 = vcl_acos(-1.0)/2;
185 m_VerboseProgress = false;
187 virtual ~RelativePositionPropImageFilter() {}
188 void PrintSelf(std::ostream& os, Indent indent) const;
190 //void GenerateThreadedData(const typename TOutputImage::RegionType& outputRegionForThread, int threadId);
194 RelativePositionPropImageFilter(const Self&); //purposely not implemented
195 void operator=(const Self&); //purposely not implemented
204 unsigned int m_Radius;
206 bool m_VerboseProgress;
208 VectorType m_DirectionVector;
211 * 2 pass instead of 2^NDimension. Warning this may cause some artifacts
215 //allocation et initialisation de la carte de correspondance
216 typename CorrespondanceMapType::Pointer InitCorrespondanceMap();
218 //compute the tabulation map
219 typename TabulationImageType::Pointer ComputeAngleTabulation();
224 } // end namespace itk
226 #ifndef ITK_MANUAL_INSTANTIATION
227 #include "RelativePositionPropImageFilter.txx"