std::string orientation,
bool uniqueConnectedComponent=false,
double spacing=-1,
- bool notflag=false);
+ bool autocropflag=true,
+ bool singleObjectCCL=true);
//--------------------------------------------------------------------
// In a binary image, search for the point belonging to the FG that
{
typename ImageType::Pointer working_image;
working_image = Labelize<ImageType>(input, BG, isFullyConnected, minimalComponentSize);
- working_image = RemoveLabels<ImageType>(working_image, BG, param->GetLabelsToRemove());
+ if (param->GetLabelsToRemove().size() != 0)
+ working_image = RemoveLabels<ImageType>(working_image, BG, param->GetLabelsToRemove());
working_image = KeepLabels<ImageType>(working_image,
BG, FG,
param->GetFirstKeep(),
std::string orientation,
bool uniqueConnectedComponent,
double spacing,
- bool inverseflag)
+ bool autocropFlag,
+ bool singleObjectCCL)
{
typedef SliceBySliceRelativePositionFilter<MaskImageType> SliceRelPosFilterType;
typename SliceRelPosFilterType::Pointer sliceRelPosFilter = SliceRelPosFilterType::New();
sliceRelPosFilter->SetIntermediateSpacingFlag((spacing != -1));
sliceRelPosFilter->SetIntermediateSpacing(spacing);
sliceRelPosFilter->SetUniqueConnectedComponentBySlice(uniqueConnectedComponent);
- sliceRelPosFilter->SetInverseOrientationFlag(inverseflag);
- // sliceRelPosFilter->SetAutoCropFlag(true); ??
+ sliceRelPosFilter->SetUseASingleObjectConnectedComponentBySliceFlag(singleObjectCCL);
+ // sliceRelPosFilter->SetInverseOrientationFlag(inverseflag);
+ sliceRelPosFilter->SetAutoCropFlag(autocropFlag);
+ sliceRelPosFilter->IgnoreEmptySliceObjectFlagOn();
sliceRelPosFilter->Update();
return sliceRelPosFilter->GetOutput();
}
itkSetMacro(IgnoreEmptySliceObjectFlag, bool);
itkBooleanMacro(IgnoreEmptySliceObjectFlag);
+ itkGetConstMacro(UseASingleObjectConnectedComponentBySliceFlag, bool);
+ itkSetMacro(UseASingleObjectConnectedComponentBySliceFlag, bool);
+ itkBooleanMacro(UseASingleObjectConnectedComponentBySliceFlag);
+
protected:
SliceBySliceRelativePositionFilter();
virtual ~SliceBySliceRelativePositionFilter() {}
bool m_UniqueConnectedComponentBySlice;
int m_Direction;
bool m_IgnoreEmptySliceObjectFlag;
+ bool m_UseASingleObjectConnectedComponentBySliceFlag;
private:
SliceBySliceRelativePositionFilter(const Self&); //purposely not implemented
SetDirection(2);
UniqueConnectedComponentBySliceOff();
SetIgnoreEmptySliceObjectFlag(false);
+ UseASingleObjectConnectedComponentBySliceFlagOn();
+ this->VerboseStepFlagOff();
+ this->WriteStepFlagOff();
this->SetCombineWithOrFlag(false);
}
//--------------------------------------------------------------------
// Perform slice by slice relative position
this->StartNewStep("Perform slice by slice relative position");
for(unsigned int i=0; i<mInputSlices.size(); i++) {
- // Select main CC in each object slice (required ?)
+
+ // Count the number of CCL (allow to ignore empty slice)
int nb=0;
mObjectSlices[i] = LabelizeAndCountNumberOfObjects<SliceType>(mObjectSlices[i], 0, true, 1, nb);
if ((!GetIgnoreEmptySliceObjectFlag()) || (nb!=0)) {
- mObjectSlices[i] = KeepLabels<SliceType>(mObjectSlices[i], 0, 1, 1, 1, true);
+
+ // Select or not a single CCL ?
+ if (GetUseASingleObjectConnectedComponentBySliceFlag()) {
+ mObjectSlices[i] = KeepLabels<SliceType>(mObjectSlices[i], 0, 1, 1, 1, true);
+ }
// Relative position
typedef clitk::AddRelativePositionConstraintToLabelImageFilter<SliceType> RelPosFilterType;