]> Creatis software - clitk.git/blob - vv/vvToolSegmentation.h
Debug RTStruct conversion with empty struc
[clitk.git] / vv / vvToolSegmentation.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://www.centreleonberard.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 #ifndef VVTOOLSEGMENTATION_H
19 #define VVTOOLSEGMENTATION_H
20
21 #include <QtGlobal>
22 #if QT_VERSION >= 0x050000
23 #include <QtUiPlugin/QDesignerExportWidget>
24 #else
25 #include <QtDesigner/QDesignerExportWidget>
26 #endif
27
28 #include "vvToolBase.h"
29 #include "vvToolWidgetBase.h"
30 #include "vvROIActor.h"
31 #include "ui_vvToolSegmentation.h"
32
33 #include "vtkLookupTable.h"
34
35 //------------------------------------------------------------------------------
36 class vvToolSegmentation:
37   public vvToolWidgetBase,
38   public vvToolBase<vvToolSegmentation>, 
39   private Ui::vvToolSegmentation 
40 {
41   Q_OBJECT
42     public:
43   vvToolSegmentation(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
44   ~vvToolSegmentation();
45
46   //-----------------------------------------------------
47   static void Initialize();
48   virtual void InputIsSelected(vvSlicerManager * m);
49   void OpenBinaryImage();
50   void RegionGrowing();
51   void Erode();
52   void Dilate();
53   void Labelize();
54   void Merge();
55   void RemoveLabel();
56   void UpdateAndRenderNewMask();
57
58   //-----------------------------------------------------
59   public slots:
60   virtual void apply();
61   void KeyPressed(std::string KeyPress);
62   virtual bool close();
63   virtual void MousePositionChanged(int slicer);
64
65  protected:
66   Ui::vvToolSegmentation ui;
67   QSharedPointer<vvROIActor> mRefMaskActor;
68   QSharedPointer<vvROIActor> mCurrentMaskActor;
69   std::vector<QSharedPointer<vvROIActor> > mCurrentCCLActors;
70   vvImage::Pointer mRefMaskImage;
71   vvImage::Pointer mCurrentMaskImage;
72   vvImage::Pointer mCurrentCCLImage;
73   int mKernelValue;
74   vtkSmartPointer<vtkLookupTable> mDefaultLUTColor;
75   enum { State_Default, State_CCL};
76   int mCurrentState;
77
78   QSharedPointer<vvROIActor> CreateMaskActor(vvImage::Pointer image, int i, int colorID, bool BGMode=false);
79   
80   double mCurrentLabelUnderMousePointer;
81   std::vector<double> mCurrentMousePositionInMM;
82   //std::vector<double> mCurrentMousePositionInPixel;
83   double GetBackgroundValue() { return 0; }
84   double GetForegroundValue() { return 1; }
85   long ComputeNumberOfPixels(vvImage::Pointer image, double value);
86
87   // Compute and store sizes of mask Foreground
88   void   UpdateMaskSize(vvImage::Pointer image, long & pix, double & cc);
89   void   UpdateMaskSizeLabels();
90   long   mRefMaskSizeInPixels;
91   double mRefMaskSizeInCC;
92   long   mCurrentMaskSizeInPixels;
93   double mCurrentMaskSizeInCC;
94
95 }; // end class vvToolSegmentation
96 //------------------------------------------------------------------------------
97
98 #endif