00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkVectorFuzzyConnectednessImageFilter_h
00018 #define __itkVectorFuzzyConnectednessImageFilter_h
00019
00020 #include "itkImage.h"
00021 #include "itkImageToImageFilter.h"
00022 #include "itkVector.h"
00023 #include "itkMatrix.h"
00024 #include <vector>
00025 #include <list>
00026
00027 #define MAX_SCALE 8
00028
00029
00030 namespace itk{
00031
00160 template <class TInputImage, class TOutputImage>
00161 class ITK_EXPORT VectorFuzzyConnectednessImageFilter:
00162 public ImageToImageFilter<TInputImage,TOutputImage>
00163 {
00164 public:
00166 typedef VectorFuzzyConnectednessImageFilter Self;
00167 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
00168 typedef SmartPointer <Self> Pointer;
00169 typedef SmartPointer<const Self> ConstPointer;
00170
00172 itkNewMacro(Self);
00173
00175 itkTypeMacro(VectorFuzzyConnectednessImageFilter,ImageToImageFilter);
00176
00178 typedef typename TInputImage::PixelType InputPixelType;
00179 typedef typename TOutputImage::PixelType OutputPixelType;
00180 typedef typename InputPixelType::VectorType InputVectorType;
00181
00183 itkStaticConstMacro(VectorDimension, unsigned int,
00184 InputPixelType::Dimension);
00185 itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
00186
00188 typedef Matrix<double, itkGetStaticConstMacro(VectorDimension),
00189 itkGetStaticConstMacro(VectorDimension)> DoubleMatrixType;
00190
00192 typedef std::vector<DoubleMatrixType> DoubleMatrixArrayType;
00193
00195 typedef Vector<unsigned short,itkGetStaticConstMacro(ImageDimension)> AffinityVector;
00196
00198 typedef Vector<double, itkGetStaticConstMacro(VectorDimension)> DoubleVectorType;
00199
00201 typedef std::vector<DoubleVectorType> DoubleVectorArrayType;
00202
00203 typedef Vector<int,2> TDVector;
00204
00206 typedef TInputImage InputImageType;
00207 typedef TOutputImage OutputImageType;
00208 typedef Image <unsigned short,itkGetStaticConstMacro(ImageDimension)> UShortImageType;
00209 typedef Image <AffinityVector, itkGetStaticConstMacro(ImageDimension)> AffinityImageType;
00210
00211 typedef typename TInputImage::IndexType IndexType;
00212 typedef typename TInputImage::SizeType SizeType;
00213 typedef typename TOutputImage::RegionType OutRegionType;
00214
00216 typedef std::list<IndexType> ListSeedType;
00217
00219 typedef std::vector<ListSeedType> ListSeedArrayType;
00220
00221 typedef std::vector<TDVector> OffsetType;
00222
00224 itkSetMacro(NumberOfObjects, int);
00225 itkGetMacro(NumberOfObjects, int);
00226
00228 void SetHomogeneityMatrix(const DoubleMatrixType homo_max);
00229
00231 void SetObjectsMatrix(const DoubleMatrixType object_max,const int object_num);
00232
00234 void SetObjectsSeed( const IndexType &seed, const int object_num);
00235
00237 void SetObjectsMean(const DoubleVectorType, const int object_num);
00238
00240 void SetSuppressBckgFlag(const int flag)
00241 {
00242 m_SuppressBckgFlag = flag;
00243 }
00244
00248 void SetThreshold(const float threshold)
00249 {
00250 m_Threshold = threshold;
00251 }
00252
00254 void Initialization();
00255
00256 protected:
00257 VectorFuzzyConnectednessImageFilter();
00258 ~VectorFuzzyConnectednessImageFilter();
00259
00260 virtual void PrintSelf(std::ostream& os, Indent indent) const;
00261
00263 void GenerateData();
00264
00265 private:
00266 SizeType m_Size;
00267 std::vector<OffsetType> m_CirclePointsLoc;
00268 std::vector<int> m_CirclePointsNum;
00269
00270 InputPixelType m_Mean;
00271 int m_SuppressBckgFlag;
00272 float m_Threshold;
00273
00274 DoubleMatrixType m_HomoCovariance;
00275
00276 int m_NumberOfObjects;
00277 DoubleMatrixArrayType m_ObjectCovariances;
00278 DoubleVectorArrayType m_ObjectMeans;
00279 ListSeedArrayType m_ObjectSeeds;
00280
00281 std::vector<char> m_ScaleArray;
00282
00283 typename InputImageType::ConstPointer m_InputImage;
00284 typename InputImageType::Pointer m_FilterImage;
00285 typename OutputImageType::Pointer m_SegmentObject;
00286 typename AffinityImageType::Pointer m_AffinityImage;
00287 typename UShortImageType::Pointer m_FuzzyConnImage;
00288
00289 void ScalePrepare();
00290 void Compute_Scale();
00291 void Compute_Filter();
00292 void Compute_Affinity(const int);
00293 double FuzzyAffinity(const InputVectorType , const InputVectorType, const int);
00294 void Fast_Tracking(const int);
00295
00296 private:
00297 VectorFuzzyConnectednessImageFilter(const Self&);
00298 void operator=(const Self&);
00299 };
00300
00301
00302 }
00303
00304 #ifndef ITK_MANUAL_INSTANTIATION
00305 #include "itkVectorFuzzyConnectednessImageFilter.txx"
00306 #endif
00307
00308 #endif