#include "bbvtkSegmentationConnectivity.h"
#include "bbvtkPackage.h"
+#include "bbtkStaticLecture.h"
+
namespace bbvtk
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SegmentationConnectivity);
void SegmentationConnectivity::bbUserSetDefaultValues()
{
thresh2 = NULL;
- cast2 = NULL;
+// cast2 = NULL;
connect2 = NULL;
cast4 = NULL;
threshold.push_back(0);
bbSetInputThresholdMinMax(threshold);
bbSetOutputOut(NULL);
+
+ bbSetInputOutputFormat("SAME");
+ bbSetInputValue(255);
+
+
}
// --------------------------------------------------------------
void SegmentationConnectivity::bbUserInitializeProcessing()
{
+
+ thresh2 = vtkImageThreshold::New();
+ thresh2->SetInValue(255);
+ thresh2->SetOutputScalarTypeToUnsignedChar();
+ connect2 = vtkImageSeedConnectivity::New();
+ connect2->SetInput(thresh2->GetOutput());
+ connect2->SetInputConnectValue(255);
+ connect2->SetOutputConnectedValue( 255 );
+ connect2->SetOutputUnconnectedValue(0);
+ cast4 = vtkImageCast::New();
+ cast4->SetInput(connect2->GetOutput());
+
+// EED 2016 06 15
+
+/*
thresh2 = vtkImageThreshold::New();
thresh2->SetInValue(255);
thresh2->SetOutputScalarTypeToUnsignedShort();
cast4 = vtkImageCast::New();
cast4->SetInput(connect2->GetOutput());
cast4->SetOutputScalarTypeToUnsignedShort();
+*/
+
}
// --------------------------------------------------------------
thresh2->Delete();
thresh2=NULL;
}
- if (cast2!=NULL)
- {
- cast2->Delete();
- cast2=NULL;
- }
+// if (cast2!=NULL)
+// {
+// cast2->Delete();
+// cast2=NULL;
+// }
if (connect2!=NULL)
{
connect2->Delete();
}
}
+
+
+
// --------------------------------------------------------------
void SegmentationConnectivity::DoProcess()
{
+ int outputformat = bbtkStaticLecture::GetTypeFormat( bbGetInputOutputFormat() , bbGetInputIn() );
+
+
+
vtkImageData *imagedata = bbGetInputIn();
imagedata->UpdateInformation();
imagedata->SetUpdateExtent(imagedata->GetWholeExtent());
thresh2->ThresholdBetween(3000, 3001);
thresh2->SetInput(imagedata);
thresh2->ThresholdBetween(bbGetInputThresholdMinMax()[0], bbGetInputThresholdMinMax()[1]);
+ thresh2->Modified();
thresh2->Update();
- cast2->Update();
+// EED 2016 06 15
+// cast2->Modified();
+// cast2->Update();
connect2->RemoveAllSeeds ();
int x = bbGetInputPositionXYZ()[0];
if ( z>=maxz ) { printf("Warnnig bbtk::vtk::SegmentationConnectivity::DoProcess limites of the image out of range z: %d -> %d \n",y, maxz-1 ); z=maxz-1; }
connect2->AddSeed( x,y,z );
+ connect2->SetOutputConnectedValue( bbGetInputValue() );
+ cast4->SetOutputScalarType( outputformat );
+
+ connect2->Modified();
connect2->Update();
cast4->Update();
bbSetOutputOut(cast4->GetOutput() );