本文整理汇总了C++中mask::Pointer类的典型用法代码示例。如果您正苦于以下问题:C++ Pointer类的具体用法?C++ Pointer怎么用?C++ Pointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
FloatVectorImageType::Pointer image = FloatVectorImageType::New();
Testing::GetBlankImage(image.GetPointer(), 4);
Mask::Pointer mask = Mask::New();
Testing::GetFullyValidMask(mask.GetPointer());
UnsignedCharScalarImageType::Pointer manualPriorityImage = UnsignedCharScalarImageType::New();
Testing::GetBlankImage(manualPriorityImage.GetPointer());
unsigned int patchRadius = 5;
typedef PriorityConfidence ConfidencePriorityType;
ConfidencePriorityType priorityConfidence(mask, patchRadius);
PriorityManual<itk::Index<2>, UnsignedCharScalarImageType, ConfidencePriorityType>
priority(manualPriorityImage, &priorityConfidence);
itk::Index<2> filledPixel = {{0,0}};
priority.Update(filledPixel);
priority.SetManualPriorityImage(manualPriorityImage);
itk::Index<2> queryPixel = {{0,0}};
priority.ComputePriority(queryPixel);
return EXIT_SUCCESS;
}
示例2: 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];
Mask::Pointer mask = Mask::New();
mask->Read(maskFilename);
typedef itk::Image<unsigned char, 2> ImageType;
ImageType::Pointer image = ImageType::New();
ITKHelpers::ReadImage(imageFilename, image.GetPointer());
FastDigitalInpainting fastDigitalInpainting;
fastDigitalInpainting.SetImage(image);
fastDigitalInpainting.SetMask(mask);
fastDigitalInpainting.SetNumberOfIterations(100);
fastDigitalInpainting.Inpaint();
ITKHelpers::WriteImage(fastDigitalInpainting.GetOutput(), outputFilename);
return EXIT_SUCCESS;
}
示例3: InitializeConfidence
void CriminisiInpainting::InitializeConfidence()
{
// Clone the mask - we need to invert the mask to actually perform the masking, but we don't want to disturb the original mask
Mask::Pointer maskClone = Mask::New();
//Helpers::DeepCopy<Mask>(this->CurrentMask, maskClone);
maskClone->DeepCopyFrom(this->CurrentMask);
// Invert the mask
typedef itk::InvertIntensityImageFilter <Mask> InvertIntensityImageFilterType;
InvertIntensityImageFilterType::Pointer invertIntensityFilter = InvertIntensityImageFilterType::New();
invertIntensityFilter->SetInput(maskClone);
//invertIntensityFilter->InPlaceOn();
invertIntensityFilter->Update();
// Convert the inverted mask to floats and scale them to between 0 and 1
// to serve as the initial confidence image
typedef itk::RescaleIntensityImageFilter< Mask, FloatScalarImageType > RescaleFilterType;
RescaleFilterType::Pointer rescaleFilter = RescaleFilterType::New();
rescaleFilter->SetInput(invertIntensityFilter->GetOutput());
rescaleFilter->SetOutputMinimum(0);
rescaleFilter->SetOutputMaximum(1);
rescaleFilter->Update();
Helpers::DeepCopy<FloatScalarImageType>(rescaleFilter->GetOutput(), this->ConfidenceImage);
//WriteImage<FloatImageType>(this->ConfidenceImage, "InitialConfidence.mhd");
}
示例4: UpdateMask
void CriminisiInpainting::UpdateMask(const itk::Index<2> inputPixel)
{
try
{
// Create a black patch
Mask::Pointer blackPatch = Mask::New();
//Helpers::CreateBlankPatch<UnsignedCharScalarImageType>(blackPatch, this->PatchRadius[0]);
Helpers::CreateConstantPatch<Mask>(blackPatch, this->CurrentMask->GetValidValue(), this->PatchRadius[0]);
itk::Index<2> pixel;
pixel[0] = inputPixel[0] - blackPatch->GetLargestPossibleRegion().GetSize()[0]/2;
pixel[1] = inputPixel[1] - blackPatch->GetLargestPossibleRegion().GetSize()[1]/2;
// Paste it into the mask
typedef itk::PasteImageFilter <Mask, Mask> PasteImageFilterType;
PasteImageFilterType::Pointer pasteFilter = PasteImageFilterType::New();
//pasteFilter->SetInput(0, this->CurrentMask);
//pasteFilter->SetInput(1, blackPatch);
pasteFilter->SetSourceImage(blackPatch);
pasteFilter->SetDestinationImage(this->CurrentMask);
pasteFilter->SetSourceRegion(blackPatch->GetLargestPossibleRegion());
pasteFilter->SetDestinationIndex(pixel);
pasteFilter->Update();
// Not sure how Mask::DeepCopyFrom would work on the output of a filter, so do this manually.
Helpers::DeepCopy<Mask>(pasteFilter->GetOutput(), this->CurrentMask);
this->CurrentMask->SetHoleValue(this->OriginalMask->GetHoleValue());
this->CurrentMask->SetValidValue(this->OriginalMask->GetValidValue());
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught in UpdateMask!" << std::endl;
std::cerr << err << std::endl;
exit(-1);
}
}
示例5: main
int main(int argc, char*argv[])
{
if(argc != 3)
{
std::cerr << "Required arguments: mask output" << std::endl;
return EXIT_FAILURE;
}
std::string maskFilename = argv[1];
std::string outputFilename = argv[2];
std::cout << "Reading mask: " << maskFilename << std::endl;
std::cout << "Output: " << outputFilename << std::endl;
Mask::Pointer mask = Mask::New();
mask->Read(maskFilename.c_str());
Mask::BoundaryImageType::Pointer boundaryImage = Mask::BoundaryImageType::New();
boundaryImage->SetRegions(mask->GetLargestPossibleRegion());
boundaryImage->Allocate();
// mask->CreateBoundaryImage(boundaryImage.GetPointer(), mask->GetValidValue());
mask->CreateBoundaryImage(boundaryImage.GetPointer(), Mask::VALID);
ITKHelpers::WriteImage(boundaryImage.GetPointer(), outputFilename);
return EXIT_SUCCESS;
}
示例6: main
int main()
{
typedef itk::Image<itk::CovariantVector<float, 3>, 2> ImageType;
// typedef FloatVectorImageType ImageType;
ImageType::Pointer image = ImageType::New();
Testing::GetBlankImage(image.GetPointer(), 4);
Mask::Pointer mask = Mask::New();
Testing::GetFullyValidMask(mask.GetPointer());
unsigned int patchRadius = 5;
PriorityCriminisi<ImageType> priority(image.GetPointer(), mask.GetPointer(),
patchRadius);
itk::Index<2> sourcePixel;
sourcePixel.Fill(0);
itk::Index<2> targetPixel;
targetPixel.Fill(1);
priority.Update(sourcePixel, targetPixel);
itk::Index<2> queryPixel = {{0,0}};
priority.ComputePriority(queryPixel);
return EXIT_SUCCESS;
}
示例7: main
// Run with: image.png image.mask 15 filled.png
int main(int argc, char *argv[])
{
// Verify arguments
if(argc != 5)
{
std::cerr << "Required arguments: image.png image.mask patchHalfWidth output.png" << std::endl;
std::cerr << "Input arguments: ";
for(int i = 1; i < argc; ++i)
{
std::cerr << argv[i] << " ";
}
return EXIT_FAILURE;
}
// Parse arguments
std::string imageFilename = argv[1];
std::string maskFilename = argv[2];
std::stringstream ssPatchRadius;
ssPatchRadius << argv[3];
unsigned int patchHalfWidth = 0;
ssPatchRadius >> patchHalfWidth;
std::string outputFilename = argv[4];
// Output arguments
std::cout << "Reading image: " << imageFilename << std::endl;
std::cout << "Reading mask: " << maskFilename << std::endl;
std::cout << "Patch half width: " << patchHalfWidth << std::endl;
std::cout << "Output: " << outputFilename << std::endl;
typedef itk::Image<itk::CovariantVector<float, 3>, 2> ImageType;
typedef itk::ImageFileReader<ImageType> ImageReaderType;
ImageReaderType::Pointer imageReader = ImageReaderType::New();
imageReader->SetFileName(imageFilename);
imageReader->Update();
ImageType::Pointer image = ImageType::New();
ITKHelpers::DeepCopy(imageReader->GetOutput(), image.GetPointer());
Mask::Pointer mask = Mask::New();
mask->Read(maskFilename);
std::cout << "Mask size: " << mask->GetLargestPossibleRegion().GetSize() << std::endl;
std::cout << "hole pixels: " << mask->CountHolePixels() << std::endl;
std::cout << "valid pixels: " << mask->CountValidPixels() << std::endl;
// Setup the GUI system
QApplication app( argc, argv );
// Without this, after we close the first dialog
// (after the first iteration that is not accepted automatically), the event loop quits.
app.setQuitOnLastWindowClosed(false);
DummyPatchesDriver(image, mask, patchHalfWidth);
return app.exec();
}
示例8: CreateBoundaryImageInRegion
void Mask::CreateBoundaryImageInRegion(const itk::ImageRegion<2>& region, BoundaryImageType* const boundaryImage,
const HoleMaskPixelTypeEnum& whichSideOfBoundary) const
{
// Create a binary image of the mask
unsigned char holeColor = 255;
unsigned char validColor = 0;
UnsignedCharImageType::Pointer fullBinaryImage = UnsignedCharImageType::New();
CreateBinaryImageInRegion(region, fullBinaryImage, holeColor, validColor);
// Extract the relevant region from the binary image
UnsignedCharImageType::Pointer binaryImage = UnsignedCharImageType::New();
binaryImage->SetRegions(region);
binaryImage->Allocate();
CopyRegion(fullBinaryImage.GetPointer(), binaryImage.GetPointer(), region, region);
// Extract the relevant region from the mask
Mask::Pointer extractedRegionMask = Mask::New();
extractedRegionMask->SetRegions(region);
extractedRegionMask->Allocate();
CopyRegion(this, extractedRegionMask.GetPointer(), region, region);
// Since the hole is white (we have specified this at the beginning of this function),
// we want the foreground value of the contour filter to be black.
// This means that the boundary will be detected in the black pixel region,
// which is on the outside edge of the hole like we want. However,
// The BinaryContourImageFilter will change all non-boundary pixels to the background color,
// so the resulting output will be inverted - the boundary pixels will be black and the
// non-boundary pixels will be white.
// Find the boundary
typedef itk::BinaryContourImageFilter<UnsignedCharImageType, UnsignedCharImageType> binaryContourImageFilterType;
binaryContourImageFilterType::Pointer binaryContourFilter = binaryContourImageFilterType::New();
binaryContourFilter->SetInput(binaryImage);
binaryContourFilter->SetFullyConnected(true);
if(whichSideOfBoundary == HoleMaskPixelTypeEnum::VALID)
{
// we want the boundary pixels to be in the valid region.
binaryContourFilter->SetForegroundValue(validColor);
binaryContourFilter->SetBackgroundValue(holeColor);
}
else if(whichSideOfBoundary == HoleMaskPixelTypeEnum::HOLE)
{
// we want the boundary pixels to be in the hole region.
binaryContourFilter->SetForegroundValue(holeColor);
binaryContourFilter->SetBackgroundValue(validColor);
}
else
{
throw std::runtime_error("An invalid side of the boundary was requested.");
}
binaryContourFilter->Update();
DeepCopy(binaryContourFilter->GetOutput(), boundaryImage);
}
示例9: Vector
void Vector()
{
typedef itk::Image<unsigned char, 2 > ChannelType;
const unsigned int NumberOfChannels = 3;
typedef itk::Image<itk::CovariantVector<unsigned char, NumberOfChannels>, 2 > ImageType;
ImageType::Pointer image = ImageType::New();
itk::Index<2> corner = {{0,0}};
itk::Size<2> imageSize = {{500,500}};
itk::ImageRegion<2> fullRegion(corner, imageSize);
image->SetRegions(fullRegion);
image->Allocate();
for(unsigned int i = 0; i < NumberOfChannels; ++i)
{
itk::RandomImageSource<ChannelType>::Pointer randomImageSource =
itk::RandomImageSource<ChannelType>::New();
randomImageSource->SetNumberOfThreads(1); // to produce non-random results
randomImageSource->SetSize(imageSize);
randomImageSource->Update();
ITKHelpers::SetChannel(image.GetPointer(), i, randomImageSource->GetOutput());
}
itk::Size<2> patchSize = {{21,21}};
// There is nothing magic about these particular patches
itk::Index<2> targetCorner = {{319, 302}};
itk::ImageRegion<2> targetRegion(targetCorner, patchSize);
itk::Index<2> sourceCorner = {{341, 300}};
itk::ImageRegion<2> sourceRegion(sourceCorner, patchSize);
Mask::Pointer mask = Mask::New();
mask->SetRegions(fullRegion);
mask->Allocate();
ITKHelpers::SetImageToConstant(mask.GetPointer(), mask->GetValidValue());
typedef SumSquaredPixelDifference<ImageType::PixelType> PixelDifferenceType;
typedef ImagePatchPixelDescriptor<ImageType> PatchType;
ImagePatchDifference<PatchType, PixelDifferenceType> imagePatchDifference;
PatchType targetPatch(image, mask, targetRegion);
PatchType sourcePatch(image, mask, sourceRegion);
float difference = imagePatchDifference(targetPatch, sourcePatch);
std::cout << "GMHDifference: " << difference << std::endl;
}
示例10: 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;
}
示例11: FindBoundary
void Mask::FindBoundary(UnsignedCharScalarImageType* boundaryImage) const
{
// Compute the "outer" boundary of the region to fill. That is, we want the boundary pixels to be in the source region.
//HelpersOutput::WriteImageConditional<Mask>(this->CurrentMask, "Debug/FindBoundary.CurrentMask.mha", this->DebugImages);
//HelpersOutput::WriteImageConditional<Mask>(this->CurrentMask, "Debug/FindBoundary.CurrentMask.png", this->DebugImages);
// Create a binary image (throw away the "dont use" pixels)
Mask::Pointer holeOnly = Mask::New();
holeOnly->DeepCopyFrom(this);
itk::ImageRegionIterator<Mask> maskIterator(holeOnly, holeOnly->GetLargestPossibleRegion());
// This should result in a white hole on a black background
while(!maskIterator.IsAtEnd())
{
itk::Index<2> currentPixel = maskIterator.GetIndex();
if(!holeOnly->IsHole(currentPixel))
{
holeOnly->SetPixel(currentPixel, holeOnly->GetValidValue());
}
++maskIterator;
}
//HelpersOutput::WriteImageConditional<Mask>(holeOnly, "Debug/FindBoundary.HoleOnly.mha", this->DebugImages);
//HelpersOutput::WriteImageConditional<Mask>(holeOnly, "Debug/FindBoundary.HoleOnly.png", this->DebugImages);
// Since the hole is white, we want the foreground value of the contour filter to be black. This means that the boundary will
// be detected in the black pixel region, which is on the outside edge of the hole like we want. However,
// The BinaryContourImageFilter will change all non-boundary pixels to the background color, so the resulting output will be inverted -
// the boundary pixels will be black and the non-boundary pixels will be white.
// Find the boundary
typedef itk::BinaryContourImageFilter <Mask, Mask> binaryContourImageFilterType;
binaryContourImageFilterType::Pointer binaryContourFilter = binaryContourImageFilterType::New();
binaryContourFilter->SetInput(holeOnly);
binaryContourFilter->SetFullyConnected(true);
binaryContourFilter->SetForegroundValue(holeOnly->GetValidValue());
binaryContourFilter->SetBackgroundValue(holeOnly->GetHoleValue());
binaryContourFilter->Update();
//HelpersOutput::WriteImageConditional<Mask>(binaryContourFilter->GetOutput(), "Debug/FindBoundary.Boundary.mha", this->DebugImages);
//HelpersOutput::WriteImageConditional<Mask>(binaryContourFilter->GetOutput(), "Debug/FindBoundary.Boundary.png", this->DebugImages);
// Since we want to interpret non-zero pixels as boundary pixels, we must invert the image.
typedef itk::InvertIntensityImageFilter <Mask> InvertIntensityImageFilterType;
InvertIntensityImageFilterType::Pointer invertIntensityFilter = InvertIntensityImageFilterType::New();
invertIntensityFilter->SetInput(binaryContourFilter->GetOutput());
invertIntensityFilter->SetMaximum(255);
invertIntensityFilter->Update();
//this->BoundaryImage = binaryContourFilter->GetOutput();
//this->BoundaryImage->Graft(binaryContourFilter->GetOutput());
ITKHelpers::DeepCopy<UnsignedCharScalarImageType>(invertIntensityFilter->GetOutput(), boundaryImage);
//HelpersOutput::WriteImageConditional<UnsignedCharScalarImageType>(this->BoundaryImage, "Debug/FindBoundary.BoundaryImage.mha", this->DebugImages);
}
示例12: CreateMask
static void CreateMask(Mask::Pointer mask)
{
itk::Size<2> size;
size.Fill(20);
itk::Index<2> start;
start.Fill(0);
itk::ImageRegion<2> region(start,size);
mask->SetRegions(region);
mask->Allocate();
mask->FillBuffer(mask->GetValidValue());
itk::ImageRegionIterator<Mask> iterator(mask, mask->GetLargestPossibleRegion());
while(!iterator.IsAtEnd())
{
if(iterator.GetIndex()[0] > 5 && iterator.GetIndex()[0] < 15 &&
iterator.GetIndex()[1] > 5 && iterator.GetIndex()[1] < 15)
{
mask->SetPixel(iterator.GetIndex(), mask->GetHoleValue());
}
++iterator;
}
}
示例13: main
int main(int argc, char*argv[])
{
Mask::Pointer mask = Mask::New();
CreateMask(mask);
OutputHelpers::WriteImage(mask.GetPointer(), "mask.png");
UnsignedCharScalarImageType::Pointer image = UnsignedCharScalarImageType::New();
CreateImage(image);
OutputHelpers::WriteImage(image.GetPointer(), "image.png");
FloatScalarImageType::Pointer output = FloatScalarImageType::New();
MaskOperations::MaskedLaplacian(image.GetPointer(), mask.GetPointer(), output.GetPointer());
OutputHelpers::WriteImage(output.GetPointer(), "laplacian.mha");
return EXIT_SUCCESS;
}
示例14: main
int main()
{
FloatVectorImageType::Pointer image = FloatVectorImageType::New();
Testing::GetBlankImage(image.GetPointer(), 4);
Mask::Pointer mask = Mask::New();
Testing::GetFullyValidMask(mask.GetPointer());
unsigned int patchRadius = 5;
PriorityDepth<FloatVectorImageType> priority(image, mask, patchRadius);
itk::Index<2> filledPixel = {{0,0}};
priority.Update(filledPixel);
itk::Index<2> queryPixel = {{0,0}};
priority.ComputePriority(queryPixel);
return EXIT_SUCCESS;
}
示例15: main
int main(int argc, char*argv[])
{
if(argc != 2)
{
std::cerr << "Required arguments: mask" << std::endl;
return EXIT_FAILURE;
}
std::string maskFilename = argv[1];
std::cout << "Reading mask: " << maskFilename << std::endl;
Mask::Pointer mask = Mask::New();
mask->Read(maskFilename.c_str());
std::cout << "There are " << mask->CountBoundaryPixels() << " boundary pixels." << std::endl;
return EXIT_SUCCESS;
}