1 /*=========================================================================
3 Module: $RCSfile: bbvtkSegmentationConnectivity.cxx,v $
5 Date: $Date: 2009/05/15 14:58:01 $
6 Version: $Revision: 1.5 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
40 #include "bbvtkSegmentationConnectivity.h"
41 #include "bbvtkPackage.h"
46 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SegmentationConnectivity);
47 BBTK_BLACK_BOX_IMPLEMENTATION(SegmentationConnectivity,
48 bbtk::AtomicBlackBox);
51 // --------------------------------------------------------------
52 void SegmentationConnectivity::bbUserSetDefaultValues()
60 std::vector<int> position;
61 position.push_back(0);
62 position.push_back(0);
63 position.push_back(0);
64 bbSetInputPositionXYZ(position);
65 std::vector<int> threshold;
66 threshold.push_back(0);
67 threshold.push_back(0);
68 bbSetInputThresholdMinMax(threshold);
72 // --------------------------------------------------------------
73 void SegmentationConnectivity::bbUserInitializeProcessing()
75 thresh2 = vtkImageThreshold::New();
76 thresh2->SetInValue(255);
77 thresh2->SetOutputScalarTypeToUnsignedShort();
78 thresh2->SetOutValue(0);
79 cast2 = vtkImageCast::New();
80 cast2->SetInput(thresh2->GetOutput());
81 cast2->SetOutputScalarTypeToUnsignedChar();
82 connect2 = vtkImageSeedConnectivity::New();
83 connect2->SetInput(cast2->GetOutput());
84 connect2->SetInputConnectValue(255);
85 connect2->SetOutputConnectedValue(255);
86 connect2->SetOutputUnconnectedValue(0);
87 cast4 = vtkImageCast::New();
88 cast4->SetInput(connect2->GetOutput());
89 cast4->SetOutputScalarTypeToUnsignedShort();
92 // --------------------------------------------------------------
93 void SegmentationConnectivity::bbUserFinalizeProcessing()
118 // --------------------------------------------------------------
119 void SegmentationConnectivity::DoProcess()
121 vtkImageData *imagedata = bbGetInputIn();
122 imagedata->UpdateInformation();
123 imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
125 thresh2->ThresholdBetween(3000, 3001);
126 thresh2->SetInput(imagedata);
127 thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
130 connect2->RemoveAllSeeds ();
131 connect2->AddSeed( bbGetInputPositionXYZ()[0] , bbGetInputPositionXYZ()[1] , bbGetInputPositionXYZ()[2] );
135 bbSetOutputOut(cast4->GetOutput() );
139 }// EO namespace bbvtk