1 /*=========================================================================
4 Module: $RCSfile: bbvtkSegmentationConnectivity.cxx,v $
6 Date: $Date: 2008/05/09 10:39:47 $
7 Version: $Revision: 1.3 $
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.
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.
17 =========================================================================*/
27 #include "bbvtkSegmentationConnectivity.h"
28 #include "bbvtkPackage.h"
33 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SegmentationConnectivity);
34 BBTK_BLACK_BOX_IMPLEMENTATION(SegmentationConnectivity,
35 bbtk::AtomicBlackBox);
38 void SegmentationConnectivity::bbUserConstructor()
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);
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();
69 void SegmentationConnectivity::bbUserDestructor()
77 void SegmentationConnectivity::DoProcess()
79 vtkImageData *imagedata = bbGetInputIn();
80 imagedata->UpdateInformation();
81 imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
83 thresh2->ThresholdBetween(3000, 3001);
84 thresh2->SetInput(imagedata);
85 thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
88 connect2->RemoveAllSeeds ();
89 connect2->AddSeed( bbGetInputPositionXYZ()[0] , bbGetInputPositionXYZ()[1] , bbGetInputPositionXYZ()[2] );
93 bbSetOutputOut(cast4->GetOutput() );
97 }// EO namespace bbvtk