filter->SetArgsInfo(args_info);
- try {
+ try {
filter->Update();
} catch(std::runtime_error e) {
std::cout << e.what() << std::endl;
option "output" o "Output image filename" string yes
section "Used determined crop"
-option "boundingBox" b "Bounding box of the crop region (in 2D: =x1,y2, x2,y2)" int no multiple
+option "boundingBox" b "Bounding box of the crop region (in 3D: =x1,x2,y1,y2,z1,z2)" int no multiple
option "lower" l "Size of the lower crop region (multiple values)" int no multiple
option "upper" u "Size of the upper crop region (multiple values)" int no multiple
option "origin" - "Set new origin to zero" flag off
{
// Reading input
typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
+ typename ImageType::RegionType input_region = input->GetLargestPossibleRegion();
// Check options
if (mArgsInfo.BG_given && mArgsInfo.like_given)
// ------------------------------------------------
typename ImageType::SizeType lSize;
typename ImageType::SizeType uSize;
+ if (mArgsInfo.verbose_flag) std::cout << "input region " << input_region << std::endl;
if (mArgsInfo.boundingBox_given) {
for(unsigned int i=0; i<ImageType::ImageDimension; i++) {
lSize[i] = mArgsInfo.boundingBox_arg[2*i];
- uSize[i] = input->GetLargestPossibleRegion().GetSize()[i]-mArgsInfo.boundingBox_arg[2*i+1]-1;
+ uSize[i] = input_region.GetSize()[i]-mArgsInfo.boundingBox_arg[2*i+1]-1;
}
}
else {
}
else uSize.Fill(0);
}
+
+ if (mArgsInfo.verbose_flag) {
+ std::cout << "lower " << lSize << " upper " << uSize << std::endl;
+ }
+
typedef itk::CropImageFilter<ImageType, ImageType> CropImageFilterType;
typename CropImageFilterType::Pointer filter=CropImageFilterType::New();
filter->SetInput(input);
origin.Fill(itk::NumericTraits<double>::Zero);
output->SetOrigin(origin);
}
+
+ // force index to zero
+ typename ImageType::RegionType region;
+ region = output->GetLargestPossibleRegion();
+ typename ImageType::IndexType index;
+ index.Fill(itk::NumericTraits<double>::Zero);
+ region.SetIndex(index);
+ output->SetRegions(region);
// Write/Save results
this->template SetNextOutput<ImageType>(output);
clipper->SetInput(mHiddenImage->GetVTKImages()[0]);
else
clipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]);
+
squares->SetInput(clipper->GetOutput());
squaresMapper->SetInput(squares->GetOutput());
squaresMapper->ScalarVisibilityOff();
clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2],
extent2[3],extent2[4],extent2[5]);
- //std::cout << mTSlice << " " << mSlice << " " << extent2[0] << " " << extent2[1] << " " << extent2[2] << " " << extent2[3] << " " << extent2[4] << " " << extent2[5] << std::endl;
-
if (mHiddenImageIsUsed) delete extent2;
// Move the actor to be visible
position[orientation] = -1;
actor->SetPosition(position);
-// switch (orientation) {
-// case 0:
-// actor->SetPosition(-1,0,0);
-// /*
-// // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0]);
-// if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) {
-// actor->SetPosition(1,0,0);
-// } else {
-// actor->SetPosition(-1,0,0);
-// }*/
-// break;
-// case 1:
-// actor->SetPosition(0,-1,0);
-// /*
-// // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1]);
-// if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) {
-// actor->SetPosition(0,1,0);
-// } else {
-// actor->SetPosition(0,-1,0);
-// }
-// */
-// break;
-// case 2:
-// actor->SetPosition(0,0,-1);
-// /*
-// DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]);
-// if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) {
-// DD("1");
-// actor->SetPosition(0,0,1);
-// } else {
-// DD("-1");
-// actor->SetPosition(0,0,-1);
-// }
-// */
-// break;
-// }
-
mapper->Update();
-
-
-
}
//------------------------------------------------------------------------------
catch(clitk::ExceptionObject & e) {
DD(e.what());
QApplication::restoreOverrideCursor();
+ delete [] mArgsInfo.boundingBox_arg;
close();
}
std::ostringstream croppedImageName;
croppedImageName << "Cropped_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd";
// Retrieve result and display it
vvImage::Pointer output = filter->GetOutputVVImage();
+
AddImage(output,croppedImageName.str());
+
// End
QApplication::restoreOverrideCursor();
+ delete [] mArgsInfo.boundingBox_arg;
close();
}
//------------------------------------------------------------------------------