本文整理汇总了C++中mask::Pointer::CountValidPixels方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::CountValidPixels方法的具体用法?C++ Pointer::CountValidPixels怎么用?C++ Pointer::CountValidPixels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mask::Pointer
的用法示例。
在下文中一共展示了Pointer::CountValidPixels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: main
// Run with: Data/trashcan.mha Data/trashcan_mask.mha 15 filled.mha
int main(int argc, char *argv[])
{
// Verify arguments
if(argc != 6)
{
std::cerr << "Required arguments: image.mha imageMask.mha patchHalfWidth neighborhoodRadius output.mha" << 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;
// The percent of the image size to use as the neighborhood (0 - 1)
std::stringstream ssNeighborhoodPercent;
ssNeighborhoodPercent << argv[4];
float neighborhoodPercent = 0;
ssNeighborhoodPercent >> neighborhoodPercent;
std::string outputFileName = argv[5];
// 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 << "Neighborhood percent: " << neighborhoodPercent << std::endl;
std::cout << "Output: " << outputFileName << std::endl;
typedef itk::Image<itk::CovariantVector<int, 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 << "hole pixels: " << mask->CountHolePixels() << std::endl;
std::cout << "valid pixels: " << mask->CountValidPixels() << std::endl;
typedef ImagePatchPixelDescriptor<ImageType> ImagePatchPixelDescriptorType;
// Create the graph
typedef boost::grid_graph<2> VertexListGraphType;
boost::array<std::size_t, 2> graphSideLengths = { { imageReader->GetOutput()->GetLargestPossibleRegion().GetSize()[0],
imageReader->GetOutput()->GetLargestPossibleRegion().GetSize()[1] } };
// VertexListGraphType graph(graphSideLengths);
std::shared_ptr<VertexListGraphType> graph(new VertexListGraphType(graphSideLengths));
typedef boost::graph_traits<VertexListGraphType>::vertex_descriptor VertexDescriptorType;
//ImagePatchDescriptorMapType smallImagePatchDescriptorMap(num_vertices(graph), indexMap);
// Create the patch inpainter. The inpainter needs to know the status of each pixel to determine if they should be inpainted.
typedef PatchInpainter<ImageType> ImageInpainterType;
std::shared_ptr<ImageInpainterType> imagePatchInpainter(new
ImageInpainterType(patchHalfWidth, image, mask));
// Create the priority function
typedef PriorityRandom PriorityType;
std::shared_ptr<PriorityType> priorityFunction(new PriorityType);
// typedef PriorityCriminisi<ImageType> PriorityType;
// std::shared_ptr<PriorityType> priorityFunction(new PriorityType(image, mask, patchHalfWidth));
typedef IndirectPriorityQueue<VertexListGraphType> BoundaryNodeQueueType;
std::shared_ptr<BoundaryNodeQueueType> boundaryNodeQueue(new BoundaryNodeQueueType(*graph));
// Create the descriptor map. This is where the data for each pixel is stored.
typedef boost::vector_property_map<ImagePatchPixelDescriptorType, BoundaryNodeQueueType::IndexMapType> ImagePatchDescriptorMapType;
// ImagePatchDescriptorMapType imagePatchDescriptorMap(num_vertices(graph), indexMap);
std::shared_ptr<ImagePatchDescriptorMapType> imagePatchDescriptorMap(new
ImagePatchDescriptorMapType(num_vertices(*graph), *(boundaryNodeQueue->GetIndexMap())));
// Create the descriptor visitor
typedef ImagePatchDescriptorVisitor<VertexListGraphType, ImageType, ImagePatchDescriptorMapType>
ImagePatchDescriptorVisitorType;
// ImagePatchDescriptorVisitorType imagePatchDescriptorVisitor(image, mask, imagePatchDescriptorMap, patchHalfWidth);
std::shared_ptr<ImagePatchDescriptorVisitorType> imagePatchDescriptorVisitor(new
ImagePatchDescriptorVisitorType(image.GetPointer(), mask,
imagePatchDescriptorMap, patchHalfWidth));
/* ImagePatchDescriptorVisitor(TImage* const in_image, Mask* const in_mask,
std::shared_ptr<TDescriptorMap> in_descriptorMap,
const unsigned int in_half_width) : */
typedef ImagePatchDifference<ImagePatchPixelDescriptorType, SumAbsolutePixelDifference<ImageType::PixelType> >
//.........这里部分代码省略.........
示例3: main
// Run with: Data/trashcan.mha Data/trashcan_mask.mha 15 Data/trashcan.vtp Intensity filled.mha
int main(int argc, char *argv[])
{
// Verify arguments
if(argc != 6)
{
std::cerr << "Required arguments: image.mha imageMask.mha patch_half_width normals.vts output.mha" << 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 patch_half_width = 0;
ssPatchRadius >> patch_half_width;
std::string normalsFileName = argv[4];
std::string outputFilename = argv[5];
// Output arguments
std::cout << "Reading image: " << imageFilename << std::endl;
std::cout << "Reading mask: " << maskFilename << std::endl;
std::cout << "Patch half width: " << patch_half_width << std::endl;
std::cout << "Reading normals: " << normalsFileName << std::endl;
std::cout << "Output: " << outputFilename << std::endl;
vtkSmartPointer<vtkXMLStructuredGridReader> structuredGridReader = vtkSmartPointer<vtkXMLStructuredGridReader>::New();
structuredGridReader->SetFileName(normalsFileName.c_str());
structuredGridReader->Update();
typedef FloatVectorImageType 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 << "hole pixels: " << mask->CountHolePixels() << std::endl;
std::cout << "valid pixels: " << mask->CountValidPixels() << std::endl;
typedef ImagePatchPixelDescriptor<ImageType> ImagePatchPixelDescriptorType;
typedef FeatureVectorPixelDescriptor FeatureVectorPixelDescriptorType;
// Create the graph
typedef boost::grid_graph<2> VertexListGraphType;
boost::array<std::size_t, 2> graphSideLengths = { { imageReader->GetOutput()->GetLargestPossibleRegion().GetSize()[0],
imageReader->GetOutput()->GetLargestPossibleRegion().GetSize()[1] } };
VertexListGraphType graph(graphSideLengths);
typedef boost::graph_traits<VertexListGraphType>::vertex_descriptor VertexDescriptorType;
// Get the index map
typedef boost::property_map<VertexListGraphType, boost::vertex_index_t>::const_type IndexMapType;
IndexMapType indexMap(get(boost::vertex_index, graph));
// Create the priority map
typedef boost::vector_property_map<float, IndexMapType> PriorityMapType;
PriorityMapType priorityMap(num_vertices(graph), indexMap);
// Create the node fill status map. Each pixel is either filled (true) or not filled (false).
typedef boost::vector_property_map<bool, IndexMapType> FillStatusMapType;
FillStatusMapType fillStatusMap(num_vertices(graph), indexMap);
// Create the boundary status map. A node is on the current boundary if this property is true.
// This property helps the boundaryNodeQueue because we can mark here if a node has become no longer
// part of the boundary, so when the queue is popped we can check this property to see if it should
// actually be processed.
typedef boost::vector_property_map<bool, IndexMapType> BoundaryStatusMapType;
BoundaryStatusMapType boundaryStatusMap(num_vertices(graph), indexMap);
// Create the descriptor map. This is where the data for each pixel is stored.
typedef boost::vector_property_map<ImagePatchPixelDescriptorType, IndexMapType> ImagePatchDescriptorMapType;
ImagePatchDescriptorMapType imagePatchDescriptorMap(num_vertices(graph), indexMap);
// Create the descriptor map. This is where the data for each pixel is stored.
typedef boost::vector_property_map<FeatureVectorPixelDescriptorType, IndexMapType> FeatureVectorDescriptorMapType;
FeatureVectorDescriptorMapType featureVectorDescriptorMap(num_vertices(graph), indexMap);
// Create the patch inpainter. The inpainter needs to know the status of each pixel to determine if they should be inpainted.
typedef MaskedGridPatchInpainter<FillStatusMapType> InpainterType;
InpainterType patchInpainter(patch_half_width, fillStatusMap);
// Create the priority function
typedef PriorityRandom PriorityType;
PriorityType priorityFunction;
//.........这里部分代码省略.........
示例4: main
// Run with: Data/trashcan.mha Data/trashcan_mask.mha 15 filled.mha
int main(int argc, char *argv[])
{
// Verify arguments
if(argc != 5)
{
std::cerr << "Required arguments: image.mha imageMask.mha patchHalfWidth output.mha" << std::endl;
std::cerr << "Input arguments: ";
for(int i = 1; i < argc; ++i)
{
std::cerr << argv[i] << " ";
}
return EXIT_FAILURE;
}
// Setup the GUI system
QApplication app( argc, argv );
// 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 FloatVectorImageType ImageType;
typedef itk::ImageFileReader<ImageType> ImageReaderType;
ImageReaderType::Pointer imageReader = ImageReaderType::New();
imageReader->SetFileName(imageFilename);
imageReader->Update();
ImageType* image = imageReader->GetOutput();
itk::ImageRegion<2> fullRegion = imageReader->GetOutput()->GetLargestPossibleRegion();
Mask::Pointer mask = Mask::New();
mask->Read(maskFilename);
std::cout << "hole pixels: " << mask->CountHolePixels() << std::endl;
std::cout << "valid pixels: " << mask->CountValidPixels() << std::endl;
std::cout << "image has " << image->GetNumberOfComponentsPerPixel() << " components." << std::endl;
typedef ImagePatchPixelDescriptor<ImageType> ImagePatchPixelDescriptorType;
// Create the graph
typedef boost::grid_graph<2> VertexListGraphType;
boost::array<std::size_t, 2> graphSideLengths = { { fullRegion.GetSize()[0],
fullRegion.GetSize()[1] } };
VertexListGraphType graph(graphSideLengths);
typedef boost::graph_traits<VertexListGraphType>::vertex_descriptor VertexDescriptorType;
// Get the index map
typedef boost::property_map<VertexListGraphType, boost::vertex_index_t>::const_type IndexMapType;
IndexMapType indexMap(get(boost::vertex_index, graph));
// Create the priority map
typedef boost::vector_property_map<float, IndexMapType> PriorityMapType;
PriorityMapType priorityMap(num_vertices(graph), indexMap);
// Create the boundary status map. A node is on the current boundary if this property is true.
// This property helps the boundaryNodeQueue because we can mark here if a node has become no longer
// part of the boundary, so when the queue is popped we can check this property to see if it should
// actually be processed.
typedef boost::vector_property_map<bool, IndexMapType> BoundaryStatusMapType;
BoundaryStatusMapType boundaryStatusMap(num_vertices(graph), indexMap);
// Create the descriptor map. This is where the data for each pixel is stored.
typedef boost::vector_property_map<ImagePatchPixelDescriptorType, IndexMapType> ImagePatchDescriptorMapType;
ImagePatchDescriptorMapType imagePatchDescriptorMap(num_vertices(graph), indexMap);
//ImagePatchDescriptorMapType smallImagePatchDescriptorMap(num_vertices(graph), indexMap);
// Create the patch inpainter. The inpainter needs to know the status of each
// pixel to determine if they should be inpainted.
typedef MaskImagePatchInpainter InpainterType;
MaskImagePatchInpainter patchInpainter(patchHalfWidth, mask);
// Create the priority function
// typedef PriorityRandom PriorityType;
// PriorityType priorityFunction;
typedef PriorityOnionPeel PriorityType;
PriorityType priorityFunction(mask, patchHalfWidth);
// Create the boundary node queue. The priority of each node is used to order the queue.
typedef boost::vector_property_map<std::size_t, IndexMapType> IndexInHeapMap;
IndexInHeapMap index_in_heap(indexMap);
// Create the priority compare functor (we want the highest priority nodes to be first in the queue)
typedef std::greater<float> PriorityCompareType;
//.........这里部分代码省略.........