GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoFilterSemiAutoBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
34 #ifndef __QGoFilterSemiAutoBase_h
35 #define __QGoFilterSemiAutoBase_h
36 
37 #include <QObject>
38 
39 // QT
40 #include <QString>
41 #include <QWidget>
42 
43 // VTK to ITK
44 #include "vtkImageExport.h"
45 #include "itkVTKImageImport.h"
46 #include "itkImage.h"
47 
48 #include "vtkSmartPointer.h"
49 
50 // for the signals
51 #include "vtkPolyData.h"
52 
53 class vtkImageData;
54 class vtkPoints;
55 class vtkImageExport;
56 #include "QGoGUILibConfigure.h"
57 
66 class QGOGUILIB_EXPORT QGoFilterSemiAutoBase:public QObject
67 {
68  Q_OBJECT
69 public:
71  explicit QGoFilterSemiAutoBase(QObject *iParent = NULL);
72 
74  virtual ~QGoFilterSemiAutoBase();
75 
80  void setName(QString iName);
81 
86  QString getName();
87 
92  void setWidget(QWidget *iWidget);
93 
98  QWidget * getWidget();
99 
100  vtkSmartPointer<vtkImageData> getInput();
101 
102  void setOutput(vtkImageData *iOutput);
103 
104  vtkImageData * getOutput();
105 
106  void setCenter(double *iCenter);
107 
112  double * getCenter();
113 
118  double getRadius();
119 
120  int getSampling();
121 
126  int getChannel();
127 
128  void setPoints(vtkPoints *iPoints);
129 
130  vtkPoints * getPoints();
131 
132  void setOriginalImageMC(std::vector< vtkSmartPointer<vtkImageData> > *iOriginalImage);
133 
134  vtkImageData * extractOneSlice(vtkImageData *iOriginalImage, double *iOrigin, int iDirection);
135 
136  vtkPolyData * ReconstructContour(vtkImageData *iInputImage,
137  const double & iThreshold);
138 
139  vtkPolyData * ReorganizeContour(vtkPolyData *iInputImage = NULL,
140  bool iDecimate = true );
141 
142  vtkPolyData * ReconstructMesh(vtkImageData *iInputImage,
143  const double & iThreshold);
144 
145  /*
146  * \brief Connect the widget to the algorithm and to gofigure
147  * \param[in] iFilterNumber Filter to be connected
148  */
149  virtual void ConnectSignals(int iFilterNumber);
150 
151  /*
152  * \brief Convert an image from VTK to ITK
153  * \param[in] iInput VTK image to be converted
154  * \return ITK image
155  */
156  template< class PixelType, unsigned int VImageDimension >
157  typename itk::Image< PixelType, VImageDimension >::Pointer
158  ConvertVTK2ITK(vtkImageData *iInput);
159 
160  /*
161  * \brief Convert an image from ITK to VTK
162  * \param[in] iInput ITK image to be converted
163  * \return VTK image
164  */
165  template< class PixelType, unsigned int VImageDimension >
166  vtkImageData *
167  ConvertITK2VTK(typename itk::Image< PixelType, VImageDimension >::Pointer iInput);
168 
169  /*
170  * \brief Extract Region Of Interest (ROI) from an ITK image
171  * \param[in] iCenter Center of the ROI
172  * \param[in] iRadius Radius of the ROI
173  */
174  template< class PixelType, unsigned int VImageDimension >
175  typename itk::Image< PixelType, VImageDimension >::Pointer
176  ExtractROI(typename itk::Image< PixelType, VImageDimension >::Pointer,
177  double *iCenter, double iRadius);
178 
180 public slots:
181 
182  void UpdateVisibility(int iFilter);
183 
184  void setRadius(double iRadius);
185 
186  void setChannel(int iChannel = 0);
187 
188  void setSampling(int iSampling);
189 
190  void UpdateAdvancedMode(bool);
191 
192 signals:
193  void MeshCreated(vtkPolyData *, int timePoint = 0);
194 
195  void ContourCreated(vtkPolyData *);
196 
197  void ImageProcessed();
198 
199  void UpdateSeeds();
200 
201  void SegmentationFinished();
202 
203  void CreateCorrespondingMesh(int);
204 
205  void AddContourForMeshToContours(vtkPolyData *);
206 
207 private:
208  vtkImageExport * m_vtk2itkImage;
209  vtkImageData * m_Output;
212  double m_Center[3];
213  double m_Radius;
214  int m_Number;
216  vtkPoints * m_Points;
217  std::vector< vtkSmartPointer<vtkImageData> > *m_OriginalImageMC;
219 };
220 
221 #include "QGoFilterSemiAutoBase.txx"
222 
223 #endif
void setName(const char *name)
Connects the common signals regarding the seeds segmentation Provides methods to convert images from ...
std::vector< vtkSmartPointer< vtkImageData > > * m_OriginalImageMC
vtkImageExport * m_vtk2itkImage