本文整理汇总了C++中mask::Pointer::SetPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::SetPixel方法的具体用法?C++ Pointer::SetPixel怎么用?C++ Pointer::SetPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mask::Pointer
的用法示例。
在下文中一共展示了Pointer::SetPixel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: 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);
}