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