- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
- else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
- else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
- else
- {
- std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
- return;
+ // ------------------------------------------------
+ if (mArgsInfo.BG_given) { // AutoCrop filter
+ if (mArgsInfo.boundingBox_given)
+ clitkExceptionMacro("Do not use --BG and --boundingBox at the same time");
+ if (mArgsInfo.lower_given)
+ clitkExceptionMacro("Do not use --BG and --lower at the same time");
+ if (mArgsInfo.upper_given)
+ clitkExceptionMacro("Do not use --BG and --upper at the same time");
+ typedef clitk::AutoCropFilter<ImageType> FilterType;
+ typename FilterType::Pointer filter = FilterType::New();
+ filter->SetInput(input);
+ filter->SetBackgroundValue(mArgsInfo.BG_arg);
+ filter->Update();
+ output = filter->GetOutput();
+ }
+ else {
+ // ------------------------------------------------
+ if (mArgsInfo.like_given) { // CropLike filter
+ if (mArgsInfo.boundingBox_given)
+ clitkExceptionMacro("Do not use --like and --boundingBox at the same time");
+ if (mArgsInfo.lower_given)
+ clitkExceptionMacro("Do not use --like and --lower at the same time");
+ if (mArgsInfo.upper_given)
+ clitkExceptionMacro("Do not use --like and --upper at the same time");
+ typedef clitk::CropLikeImageFilter<ImageType> FilterType;
+ typename FilterType::Pointer filter = FilterType::New();
+ filter->SetInput(input);
+ filter->SetCropLikeFilename(mArgsInfo.like_arg);
+ filter->SetBackgroundValue(mArgsInfo.BGLike_arg);
+ filter->Update();
+ output = filter->GetOutput();