#include "bbUtilitiesSegmentationConnectivity.h" #include "bbUtilitiesPackage.h" namespace bbUtilities { BBTK_ADD_BLACK_BOX_TO_PACKAGE(Utilities,SegmentationConnectivity) //BBTK_USER_BLACK_BOX_IMPLEMENTATION(SegmentationConnectivity,bbtk::AtomicBlackBox); BBTK_BLACK_BOX_IMPLEMENTATION(SegmentationConnectivity,bbtk::AtomicBlackBox); void SegmentationConnectivity::Process() { vtkImageData *imagedata = bbGetInputIn(); std::vector position = bbGetInputPositionXYZ(); int x, y, z; if(imagedata != NULL){ imagedata->UpdateInformation(); imagedata->SetUpdateExtent(imagedata->GetWholeExtent()); imagedata->Update(); thresh2->SetInput(imagedata); std::cout< position; position.push_back(0); position.push_back(0); position.push_back(0); bbSetInputPositionXYZ(position); bbSetInputIn(NULL); bbSetInputThresholdMin(0); bbSetInputThresholdMax(0); bbSetOutputOut(NULL); } void SegmentationConnectivity::bbUserInitializeProcessing() { thresh2 = vtkImageThreshold::New(); thresh2->SetInValue(30000.0); thresh2->SetOutputScalarTypeToUnsignedShort(); thresh2->SetOutValue(0.0); thresh2->ReplaceInOn(); thresh2->ReplaceOutOn(); cast2 = vtkImageCast::New(); cast2->SetInput(thresh2->GetOutput()); cast2->SetOutputScalarTypeToUnsignedChar(); //cast2->SetOutputScalarTypeToUnsignedShort(); connect2 = vtkImageSeedConnectivity::New(); connect2->SetInput(cast2->GetOutput()); connect2->SetInputConnectValue(30000); connect2->SetOutputConnectedValue(30000); connect2->SetOutputUnconnectedValue(0); cast4 = vtkImageCast::New(); cast4->SetInput(connect2->GetOutput()); cast4->SetOutputScalarTypeToUnsignedShort(); } void SegmentationConnectivity::bbUserFinalizeProcessing() { thresh2->Delete(); cast2->Delete(); connect2->Delete(); cast4->Delete(); } } // EO namespace bbUtilities