GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoSetOfContoursWaterShedAlgo.cxx
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 =========================================================================*/
35 
36 #include "GoImageProcessor.h"
37 
39 QGoSetOfContoursWaterShedAlgo(std::vector< vtkPoints* >* iSeeds,
40  int iMaxThreshold, QWidget* iParent)
41  :QGoWaterShedAlgo(iSeeds, iMaxThreshold, iParent)
42 {
43  m_Sampling = new QGoAlgoParameter<int>("Sampling", false, 0, 999, 3);
45 }
46 //-------------------------------------------------------------------------
47 
48 //-------------------------------------------------------------------------
51 {
52  //this->DeleteParameters();
53  delete m_Sampling;
54 }
55 //-------------------------------------------------------------------------
56 
57 //-------------------------------------------------------------------------
58 std::vector<vtkPolyData*>
60 ApplyAlgo(GoImageProcessor* iImages,std::string iChannel, bool iIsInvertedOn)
61 {
62  std::vector<vtkPolyData*> NewContours = std::vector<vtkPolyData*>();
63  return NewContours;
64 }
65 //-------------------------------------------------------------------------
66 
67 //-------------------------------------------------------------------------
68 std::vector<std::vector<vtkPolyData*> >
70 ApplyAlgoSeveralSeeds( GoImageProcessor* iImages, std::string iChannel)
71 {
72  std::vector<std::vector<vtkPolyData*> > NewContours;
73 
74  if ( this->m_Radius->GetValue() <= 0 )
75  {
76  std::cerr << "Radius should be > 0 " << std::endl;
77  return NewContours;
78  }
79 
80  double Center[3];
81  std::vector<double> CenterVect(3);
82 
83  // LOOP FOR EACH SEED
84  for( size_t id = 0; id < this->m_Seeds->size(); id++ )
85  {
86  unsigned int dimension2Collapse(0);
87  if(id == 0)
88  {
89  dimension2Collapse = 2; // we are in XY view, collapse Z
90  }
91  else if(id == 1)
92  {
93  dimension2Collapse = 1; // we are in XZ view, collapse Y
94  }
95  else if(id == 2)
96  {
97  dimension2Collapse = 0; // we are in YZ view, collapse X
98  }
99 
100  for ( int i = 0; i < (*this->m_Seeds)[id]->GetNumberOfPoints(); i++ )
101  {
102  std::cout << "dimension2Collapse: " << dimension2Collapse << std::endl;
103  (*this->m_Seeds)[id]->GetPoint(i, Center);
104 
105  CenterVect[0] = Center[0];
106  CenterVect[1] = Center[1];
107  CenterVect[2] = Center[2];
108 
109  std::vector<vtkPolyData*> temp_output =
110  this->ApplyWaterShedFilter< unsigned char >(
111  CenterVect,
112  iImages->getImageITK< unsigned char, 3>(iChannel),//input raw image
113  dimension2Collapse);// axe to be collapsed(0=x, 1=y, 2=z)
114 
115  NewContours.push_back( temp_output );
116  }
117  }
118 
119  return NewContours;
120 }
std::vector< vtkPoints * > * m_Seeds
QGoSetOfContoursWaterShedAlgo(std::vector< vtkPoints * > *iSeeds, int iMaxThreshold, QWidget *iParent=0)
itk::Image< PixelType, VImageDimension >::Pointer getImageITK(std::string iIndex, bool iIsInverted=false)
get an ITK image (vs vtkImageData) given its index
QGoAlgorithmWidget * m_AlgoWidget
std::vector< std::vector< vtkPolyData * > > ApplyAlgoSeveralSeeds(GoImageProcessor *iImages, std::string iChannel)
unsigned int GetNumberOfPoints() const
QGoAlgoParameter< double > * m_Radius
void AddParameter(QGoAlgoParameter< T > *iParameter)
std::vector< vtkPolyData * > ApplyAlgo(GoImageProcessor *iImages, std::string iChannel, bool iIsInvertedOn=false)
return the vtkpolydata created by the algorithm
Interface between image reader and vtkImageData.
class to be the interface between the watershed algo for meshes and GoFigure