]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkSegmentationConnectivity.cxx
*** empty log message ***
[bbtk.git] / packages / vtk / src / bbvtkSegmentationConnectivity.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbvtkSegmentationConnectivity.cxx,v $
4   Language:  C++
5   Date:      $Date: 2008/10/17 08:18:30 $
6   Version:   $Revision: 1.4 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32  *  \file 
33  *  \brief 
34  */
35
36
37 #ifdef _USE_VTK_
38
39
40 #include "bbvtkSegmentationConnectivity.h"
41 #include "bbvtkPackage.h"
42
43 namespace bbvtk
44 {
45
46   BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SegmentationConnectivity);
47   BBTK_BLACK_BOX_IMPLEMENTATION(SegmentationConnectivity,
48                                 bbtk::AtomicBlackBox);
49   
50   
51   void SegmentationConnectivity::bbUserConstructor() 
52   { 
53     bbSetInputIn(NULL);
54     std::vector<int> position;
55     position.push_back(0);
56     position.push_back(0);
57     position.push_back(0);
58     bbSetInputPositionXYZ(position);
59     std::vector<int> threshold;
60     threshold.push_back(0);
61     threshold.push_back(0);
62     bbSetInputThresholdMinMax(threshold);
63     bbSetOutputOut(NULL);
64     thresh2 = vtkImageThreshold::New();
65     thresh2->SetInValue(255);
66     thresh2->SetOutputScalarTypeToUnsignedShort();
67     thresh2->SetOutValue(0);
68     cast2 = vtkImageCast::New();
69     cast2->SetInput(thresh2->GetOutput());
70     cast2->SetOutputScalarTypeToUnsignedChar();
71     connect2 = vtkImageSeedConnectivity::New();
72     connect2->SetInput(cast2->GetOutput());
73     connect2->SetInputConnectValue(255);
74     connect2->SetOutputConnectedValue(255);
75     connect2->SetOutputUnconnectedValue(0);
76     cast4 = vtkImageCast::New();
77     cast4->SetInput(connect2->GetOutput());
78     cast4->SetOutputScalarTypeToUnsignedShort();
79   }
80   
81   
82   void SegmentationConnectivity::bbUserDestructor() 
83   { 
84     thresh2->Delete();
85     cast2->Delete();
86     connect2->Delete();
87     cast4->Delete();
88   }
89
90   void SegmentationConnectivity::DoProcess()
91   {
92     vtkImageData *imagedata = bbGetInputIn();
93     imagedata->UpdateInformation();
94     imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
95     imagedata->Update();
96     thresh2->ThresholdBetween(3000, 3001);
97     thresh2->SetInput(imagedata);
98     thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
99     thresh2->Update();
100     cast2->Update();
101     connect2->RemoveAllSeeds ();
102     connect2->AddSeed( bbGetInputPositionXYZ()[0] , bbGetInputPositionXYZ()[1] , bbGetInputPositionXYZ()[2] );
103     connect2->Update();
104     cast4->Update();
105     
106     bbSetOutputOut(cast4->GetOutput() );          
107   }
108   
109
110 }// EO namespace bbvtk
111
112
113 #endif //_USE_VTK_
114
115
116
117
118