本文整理汇总了C++中mask::Pointer::ApplyToImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::ApplyToImage方法的具体用法?C++ Pointer::ApplyToImage怎么用?C++ Pointer::ApplyToImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mask::Pointer
的用法示例。
在下文中一共展示了Pointer::ApplyToImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char*argv[])
{
if(argc != 4)
{
std::cerr << "Required arguments: image mask output" << std::endl;
return EXIT_FAILURE;
}
std::string imageFilename = argv[1];
std::string maskFilename = argv[2];
std::string outputFilename = argv[3];
std::cout << "Reading image: " << imageFilename << std::endl;
std::cout << "Reading mask: " << maskFilename << std::endl;
std::cout << "Output: " << outputFilename << std::endl;
//typedef itk::Image<float, 2> ImageType;
//typedef itk::Image<itk::CovariantVector<unsigned char, 3>, 2> ImageType;
// ImageType::PixelType color;
// color[0] = 0;
// color[1] = 255;
// color[2] = 0;
typedef itk::VectorImage<float, 2> ImageType;
// ImageType::PixelType color;
// color.SetRed(0);
// color.SetGreen(255);
// color.SetBlue(0);
typedef itk::ImageFileReader<ImageType> ImageReaderType;
ImageReaderType::Pointer imageReader = ImageReaderType::New();
imageReader->SetFileName(imageFilename.c_str());
imageReader->Update();
ImageType::PixelType value(imageReader->GetOutput()->GetNumberOfComponentsPerPixel());
value.Fill(0);
Mask::Pointer mask = Mask::New();
mask->Read(maskFilename.c_str());
mask->ApplyToImage(imageReader->GetOutput(), value);
OutputHelpers::WriteImage(imageReader->GetOutput(), outputFilename);
return EXIT_SUCCESS;
}
示例2: Image
//BasicViewerWidget<TImage>::BasicViewerWidget(TImage* const image, Mask* const mask) :
BasicViewerWidget<TImage>::BasicViewerWidget(typename TImage::Pointer image, Mask::Pointer mask) :
Image(image), MaskImage(mask)
{
qRegisterMetaType<itk::ImageRegion<2> >("itkImageRegion");
this->setupUi(this);
int dims[3];
this->ImageLayer.ImageData->GetDimensions(dims);
typename TImage::Pointer tempImage = TImage::New();
ITKHelpers::DeepCopy(image.GetPointer(), tempImage.GetPointer());
typename TImage::PixelType zeroPixel(tempImage->GetNumberOfComponentsPerPixel());
zeroPixel = itk::NumericTraits<typename TImage::PixelType>::ZeroValue(zeroPixel);
mask->ApplyToImage(tempImage.GetPointer(), zeroPixel);
ITKVTKHelpers::ITKVectorImageToVTKImageFromDimension(tempImage.GetPointer(), this->ImageLayer.ImageData);
// if(chkScaleImage->isChecked())
// {
// VTKHelpers::ScaleImage(this->ImageLayer.ImageData);
// }
this->ImageDimension[0] = dims[0];
this->ImageDimension[1] = dims[1];
this->ImageDimension[2] = dims[2];
SetupScenes();
// this->InteractorStyle = vtkSmartPointer<InteractorStyleImageWithDrag>::New();
this->InteractorStyle = vtkSmartPointer<vtkInteractorStyleImage>::New();
this->Renderer = vtkSmartPointer<vtkRenderer>::New();
this->qvtkWidget->GetRenderWindow()->AddRenderer(this->Renderer);
this->Renderer->AddViewProp(ImageLayer.ImageSlice);
this->InteractorStyle->SetCurrentRenderer(this->Renderer);
this->qvtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(this->InteractorStyle);
// this->InteractorStyle->Init();
// this->Camera = new ImageCamera(this->Renderer);
this->ItkVtkCamera = new ITKVTKCamera(this->InteractorStyle, this->Renderer,
this->qvtkWidget->GetRenderWindow());
this->ItkVtkCamera->SetCameraPositionPNG();
}