]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkSegmentationConnectivity.cxx
*** empty log message ***
[bbtk.git] / packages / vtk / src / bbvtkSegmentationConnectivity.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbvtkSegmentationConnectivity.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/05/09 10:39:47 $
7   Version:   $Revision: 1.3 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18 /**
19  *  \file 
20  *  \brief 
21  */
22
23
24 #ifdef _USE_VTK_
25
26
27 #include "bbvtkSegmentationConnectivity.h"
28 #include "bbvtkPackage.h"
29
30 namespace bbvtk
31 {
32
33   BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SegmentationConnectivity);
34   BBTK_BLACK_BOX_IMPLEMENTATION(SegmentationConnectivity,
35                                 bbtk::AtomicBlackBox);
36   
37   
38   void SegmentationConnectivity::bbUserConstructor() 
39   { 
40     bbSetInputIn(NULL);
41     std::vector<int> position;
42     position.push_back(0);
43     position.push_back(0);
44     position.push_back(0);
45     bbSetInputPositionXYZ(position);
46     std::vector<int> threshold;
47     threshold.push_back(0);
48     threshold.push_back(0);
49     bbSetInputThresholdMinMax(threshold);
50     bbSetOutputOut(NULL);
51     thresh2 = vtkImageThreshold::New();
52     thresh2->SetInValue(255);
53     thresh2->SetOutputScalarTypeToUnsignedShort();
54     thresh2->SetOutValue(0);
55     cast2 = vtkImageCast::New();
56     cast2->SetInput(thresh2->GetOutput());
57     cast2->SetOutputScalarTypeToUnsignedChar();
58     connect2 = vtkImageSeedConnectivity::New();
59     connect2->SetInput(cast2->GetOutput());
60     connect2->SetInputConnectValue(255);
61     connect2->SetOutputConnectedValue(255);
62     connect2->SetOutputUnconnectedValue(0);
63     cast4 = vtkImageCast::New();
64     cast4->SetInput(connect2->GetOutput());
65     cast4->SetOutputScalarTypeToUnsignedShort();
66   }
67   
68   
69   void SegmentationConnectivity::bbUserDestructor() 
70   { 
71     thresh2->Delete();
72     cast2->Delete();
73     connect2->Delete();
74     cast4->Delete();
75   }
76
77   void SegmentationConnectivity::DoProcess()
78   {
79     vtkImageData *imagedata = bbGetInputIn();
80     imagedata->UpdateInformation();
81     imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
82     imagedata->Update();
83     thresh2->ThresholdBetween(3000, 3001);
84     thresh2->SetInput(imagedata);
85     thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
86     thresh2->Update();
87     cast2->Update();
88     connect2->RemoveAllSeeds ();
89     connect2->AddSeed( bbGetInputPositionXYZ()[0] , bbGetInputPositionXYZ()[1] , bbGetInputPositionXYZ()[2] );
90     connect2->Update();
91     cast4->Update();
92     
93     bbSetOutputOut(cast4->GetOutput() );          
94   }
95   
96
97 }// EO namespace bbvtk
98
99
100 #endif //_USE_VTK_
101
102
103
104
105