void paint_vertex(VertexDescriptorType target, VertexDescriptorType source, TGraph& g) const { itk::Index<2> target_index; target_index[0] = target[0]; target_index[1] = target[1]; itk::Index<2> source_index; source_index[0] = source[0]; source_index[1] = source[1]; assert(image->GetLargestPossibleRegion().IsInside(source_index)); assert(image->GetLargestPossibleRegion().IsInside(target_index)); Image->SetPixel(target_index, Image->GetPixel(source_index)); }
void PaintPatch(TVertexDescriptor target, TVertexDescriptor source) const { TVertexDescriptor target_patch_corner; target_patch_corner[0] = target[0] - PatchHalfWidth; target_patch_corner[1] = target[1] - PatchHalfWidth; TVertexDescriptor source_patch_corner; source_patch_corner[0] = source[0] - PatchHalfWidth; source_patch_corner[1] = source[1] - PatchHalfWidth; TVertexDescriptor target_node; TVertexDescriptor source_node; for(std::size_t i = 0; i < PatchHalfWidth * 2 + 1; ++i) { for(std::size_t j = 0; j < PatchHalfWidth * 2 + 1; ++j) { target_node[0] = target_patch_corner[0] + i; target_node[1] = target_patch_corner[1] + j; source_node[0] = source_patch_corner[0] + i; source_node[1] = source_patch_corner[1] + j; // Only paint the pixel if it is currently a hole if( MaskImage->IsHole(ITKHelpers::CreateIndex(target_node)) ) { //std::cout << "Copying pixel " << source_node << " to pixel " << target_node << std::endl; itk::Index<2> target_index = ITKHelpers::CreateIndex(target); itk::Index<2> source_index = ITKHelpers::CreateIndex(source); assert(Image->GetLargestPossibleRegion().IsInside(source_index)); assert(Image->GetLargestPossibleRegion().IsInside(target_index)); Image->SetPixel(target_index, Image->GetPixel(source_index)); } } } };