]> 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/04/24 12:56:41 $
7   Version:   $Revision: 1.1 $
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_USER_BLACK_BOX_IMPLEMENTATION(SegmentationConnectivity,bbtk::AtomicBlackBox);
35
36
37         void SegmentationConnectivity::bbUserConstructor() 
38    { 
39       bbSetInputIn(NULL);
40           std::vector<int> position;
41           position.push_back(0);
42           position.push_back(0);
43           position.push_back(0);
44           bbSetInputPositionXYZ(position);
45           std::vector<int> threshold;
46           threshold.push_back(0);
47           threshold.push_back(0);
48           bbSetInputThresholdMinMax(threshold);
49           bbSetOutputOut(NULL);
50           thresh2 = vtkImageThreshold::New();
51           thresh2->SetInValue(255);
52           thresh2->SetOutputScalarTypeToUnsignedShort();
53           thresh2->SetOutValue(0);
54           cast2 = vtkImageCast::New();
55           cast2->SetInput(thresh2->GetOutput());
56           cast2->SetOutputScalarTypeToUnsignedChar();
57           connect2 = vtkImageSeedConnectivity::New();
58           connect2->SetInput(cast2->GetOutput());
59           connect2->SetInputConnectValue(255);
60           connect2->SetOutputConnectedValue(255);
61           connect2->SetOutputUnconnectedValue(0);
62           cast4 = vtkImageCast::New();
63           cast4->SetInput(connect2->GetOutput());
64           cast4->SetOutputScalarTypeToUnsignedShort();
65    }
66
67
68   void SegmentationConnectivity::DoProcess()
69   {
70         vtkImageData *imagedata = bbGetInputIn();
71         imagedata->UpdateInformation();
72         imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
73         imagedata->Update();
74         thresh2->ThresholdBetween(3000, 3001);
75         thresh2->SetInput(imagedata);
76         thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
77         thresh2->Update();
78         cast2->Update();
79         connect2->RemoveAllSeeds ();
80         connect2->AddSeed( bbGetInputPositionXYZ()[0] , bbGetInputPositionXYZ()[1] , bbGetInputPositionXYZ()[2] );
81         connect2->Update();
82         cast4->Update();
83
84     bbSetOutputOut(cast4->GetOutput() );          
85   }
86
87
88 }// EO namespace bbvtk
89
90
91 #endif //_USE_VTK_
92
93
94
95
96