-
- _thresh = vtkImageThreshold::New();
- _thresh->SetInput(_imagedata);
- //_thresh->ReleaseDataFlagOff();
- _thresh->SetInValue(255);
- _thresh->SetOutputScalarTypeToUnsignedShort();
- _thresh->SetOutValue(0);
- //_thresh->ThresholdBetween(_sl_minSize->GetValue(), _range[1]);
- //SIL//
- _thresh->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd());
-
- vtkImageCast *cast = vtkImageCast::New();
- cast->SetInput(_thresh->GetOutput());
- cast->SetOutputScalarTypeToUnsignedChar();
- cast->Update();
-
-
- _connect = vtkImageSeedConnectivity::New();
- _connect->SetInput(cast->GetOutput());
- _connect->SetInputConnectValue(255);
- _connect->SetOutputConnectedValue(255);
- _connect->SetOutputUnconnectedValue(0);
- _connect->AddSeed((int)(puntoactualprov[0]), (int)(puntoactualprov[1]), (int)(puntoactualprov[2]));
-// _connect->Update();
-
- cast3 = vtkImageCast::New();
- cast3->SetInput(_connect->GetOutput());
- cast3->SetOutputScalarTypeToUnsignedShort();
- cast3->Update();
-//SIL//
+
+ if(_thresh==NULL){
+ _thresh = vtkImageThreshold::New();
+ //_thresh->ReleaseDataFlagOff();
+ _thresh->SetInValue(255);
+ _thresh->SetOutputScalarTypeToUnsignedShort();
+ _thresh->SetOutValue(0);
+ //_thresh->ThresholdBetween(_sl_minSize->GetValue(), _range[1]);
+ //SIL//
+ _cast = vtkImageCast::New();
+ _cast->SetInput(_thresh->GetOutput());
+ _cast->SetOutputScalarTypeToUnsignedChar();
+
+ _connect = vtkImageSeedConnectivity::New();
+ _connect->SetInput(_cast->GetOutput());
+ _connect->SetInputConnectValue(255);
+ _connect->SetOutputConnectedValue(255);
+ _connect->SetOutputUnconnectedValue(0);
+
+ cast3 = vtkImageCast::New();
+ cast3->SetInput(_connect->GetOutput());
+ cast3->SetOutputScalarTypeToUnsignedShort();
+
+ _thresh2 = vtkImageThreshold::New();
+ //_thresh2->ReleaseDataFlagOff();
+ _thresh2->SetInValue(255);
+ _thresh2->SetOutputScalarTypeToUnsignedShort();
+ _thresh2->SetOutValue(0);
+ //SIL//_thresh2->ThresholdBetween(_sl_minSize->GetValue(), _sl_maxSize->GetValue());
+
+ cast2 = vtkImageCast::New();
+ cast2->SetInput(_thresh2->GetOutput());
+ cast2->SetOutputScalarTypeToUnsignedChar();
+ _connect2 = vtkImageSeedConnectivity::New();
+ _connect2->SetInput(cast2->GetOutput());
+ _connect2->SetInputConnectValue(255);
+ _connect2->SetOutputConnectedValue(255);
+ _connect2->SetOutputUnconnectedValue(0);
+
+ cast4 = vtkImageCast::New();
+ cast4->SetInput(_connect2->GetOutput());
+ cast4->SetOutputScalarTypeToUnsignedShort();
+ }
+ _thresh->RemoveAllInputs();
+ _thresh->SetInput(_imagedata);
+ _thresh->ThresholdBetween(sl_barrange_segmentation->GetStart(), sl_barrange_segmentation->GetEnd());
+ _thresh->Update();