]> Creatis software - clitk.git/blob - itk/clitkSegmentationUtils.h
add exception if error
[clitk.git] / itk / clitkSegmentationUtils.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
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.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ======================================================================-====*/
18
19 #ifndef CLITKSEGMENTATIONUTILS_H
20 #define CLITKSEGMENTATIONUTILS_H
21
22 #include "clitkCommon.h"
23 #include "clitkAutoCropFilter.h"
24 #include "clitkLabelizeParameters.h"
25 #include <itkBoundingBox.h>
26
27 namespace clitk {
28
29   //--------------------------------------------------------------------
30   template<class ImageType>
31   void ComputeBBFromImageRegion(typename ImageType::Pointer image, 
32                                 typename ImageType::RegionType region,
33                                 typename itk::BoundingBox<unsigned long, 
34                                 ImageType::ImageDimension>::Pointer bb);
35   
36   //--------------------------------------------------------------------
37   template<int Dimension>
38   void ComputeBBIntersection(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo, 
39                              typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
40                              typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2);
41
42   //--------------------------------------------------------------------
43   template<class ImageType>
44   void ComputeRegionFromBB(typename ImageType::Pointer image, 
45                            const typename itk::BoundingBox<unsigned long, 
46                            ImageType::ImageDimension>::Pointer bb, 
47                            typename ImageType::RegionType & region);
48   //--------------------------------------------------------------------
49   template<class TInternalImageType, class TMaskInternalImageType>
50   typename TInternalImageType::Pointer
51   SetBackground(const TInternalImageType * input,
52                 const TMaskInternalImageType * mask, 
53                 typename TMaskInternalImageType::PixelType maskBG, 
54                 typename TInternalImageType::PixelType outValue);
55   //--------------------------------------------------------------------
56
57
58   //--------------------------------------------------------------------
59   template<class ImageType>
60   int GetNumberOfConnectedComponentLabels(typename ImageType::Pointer input, 
61                                           typename ImageType::PixelType BG, 
62                                           bool isFullyConnected);
63   //--------------------------------------------------------------------
64
65
66   //-------------------------------------------------------------------- 
67   template<class TImageType>
68   typename TImageType::Pointer
69   Labelize(typename TImageType::Pointer input, 
70            typename TImageType::PixelType BG, 
71            bool isFullyConnected, 
72            int minimalComponentSize);
73   //--------------------------------------------------------------------
74
75
76   //--------------------------------------------------------------------
77   template<class ImageType>
78   typename ImageType::Pointer
79   RemoveLabels(typename ImageType::Pointer input, 
80                typename ImageType::PixelType BG, 
81                std::vector<typename ImageType::PixelType> & labelsToRemove);
82   //--------------------------------------------------------------------
83
84
85   //--------------------------------------------------------------------
86   template<class ImageType>
87     typename ImageType::Pointer
88     AutoCrop(typename ImageType::Pointer input, 
89              typename ImageType::PixelType BG) {
90       typedef clitk::AutoCropFilter<ImageType> AutoCropFilterType;
91       typename AutoCropFilterType::Pointer autoCropFilter = AutoCropFilterType::New();
92       autoCropFilter->SetInput(input);
93       autoCropFilter->Update();   
94       return autoCropFilter->GetOutput();
95   }
96
97   //--------------------------------------------------------------------
98
99
100   //--------------------------------------------------------------------
101   template<class TImageType>
102   typename TImageType::Pointer
103   KeepLabels(typename TImageType::Pointer input,
104              typename TImageType::PixelType BG, 
105              typename TImageType::PixelType FG,  
106              typename TImageType::PixelType firstKeep, 
107              typename TImageType::PixelType lastKeep, 
108              bool useLastKeep);
109   //--------------------------------------------------------------------
110
111
112   //--------------------------------------------------------------------
113   template<class TImageType>
114   typename TImageType::Pointer
115   LabelizeAndSelectLabels(typename TImageType::Pointer input,
116                           typename TImageType::PixelType BG, 
117                           typename TImageType::PixelType FG, 
118                           bool isFullyConnected,
119                           int minimalComponentSize,
120                           LabelizeParameters<typename TImageType::PixelType> * param);
121
122   //--------------------------------------------------------------------
123   template<class ImageType>
124   typename ImageType::Pointer
125   EnlargeImageLike(typename ImageType::Pointer input,
126                    typename ImageType::Pointer like, 
127                    typename ImageType::PixelType BG);
128
129 }
130
131 #include "clitkSegmentationUtils.txx"
132
133 #endif