1 /*=========================================================================
4 Module: $RCSfile: bbvtkSegmentationConnectivity.cxx,v $
6 Date: $Date: 2008/04/24 14:11:31 $
7 Version: $Revision: 1.2 $
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,bbtk::AtomicBlackBox);
37 void SegmentationConnectivity::bbUserConstructor()
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);
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();
68 void SegmentationConnectivity::DoProcess()
70 vtkImageData *imagedata = bbGetInputIn();
71 imagedata->UpdateInformation();
72 imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
74 thresh2->ThresholdBetween(3000, 3001);
75 thresh2->SetInput(imagedata);
76 thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
79 connect2->RemoveAllSeeds ();
80 connect2->AddSeed( bbGetInputPositionXYZ()[0] , bbGetInputPositionXYZ()[1] , bbGetInputPositionXYZ()[2] );
84 bbSetOutputOut(cast4->GetOutput() );
88 }// EO namespace bbvtk