From 369159cd948afa6943a6da0ce335eb72c79be7a0 Mon Sep 17 00:00:00 2001 From: David Doria Date: Mon, 20 Feb 2012 18:35:24 -0500 Subject: [PATCH] DemoBadPatchRealImage working. --- ClassicalImageInpainting.cpp | 14 +- Concepts/DescriptorVisitorConcept.hpp | 4 +- Demos/CMakeLists.txt | 86 ++++++----- Demos/DemoBadPatchComparison.cpp | 5 +- Demos/DemoBadPatchRealImage.cpp | 135 +++++++++++------- DifferenceFunctions/ImagePatchDifference.hpp | 2 + Helpers/ITKHelpers.hxx | 2 +- Interactive/TopPatchesDialog.h | 5 + Interactive/TopPatchesDialog.hpp | 13 ++ Node.h | 5 + .../CompositeDescriptorVisitor.hpp | 4 +- .../DescriptorVisitorParent.h | 4 +- .../ImagePatchDescriptorVisitor.hpp | 8 +- Visitors/InpaintingVisitor.hpp | 4 +- 14 files changed, 182 insertions(+), 109 deletions(-) diff --git a/ClassicalImageInpainting.cpp b/ClassicalImageInpainting.cpp index dace807..d051dfa 100644 --- a/ClassicalImageInpainting.cpp +++ b/ClassicalImageInpainting.cpp @@ -157,18 +157,22 @@ int main(int argc, char *argv[]) typedef std::less PriorityCompareType; PriorityCompareType lessThanFunctor; - typedef boost::d_ary_heap_indirect BoundaryNodeQueueType; + typedef boost::d_ary_heap_indirect + BoundaryNodeQueueType; BoundaryNodeQueueType boundaryNodeQueue(priorityMap, index_in_heap, lessThanFunctor); // Create the descriptor visitor - typedef ImagePatchDescriptorVisitor ImagePatchDescriptorVisitorType; + typedef ImagePatchDescriptorVisitor + ImagePatchDescriptorVisitorType; ImagePatchDescriptorVisitorType imagePatchDescriptorVisitor(image, mask, imagePatchDescriptorMap, patch_half_width); // Create the inpainting visitor typedef InpaintingVisitor InpaintingVisitorType; + ImagePatchDescriptorVisitorType, PriorityType, PriorityMapType, BoundaryStatusMapType> + InpaintingVisitorType; InpaintingVisitorType inpaintingVisitor(image, mask, boundaryNodeQueue, fillStatusMap, - imagePatchDescriptorVisitor, priorityMap, &priorityFunction, patch_half_width, boundaryStatusMap); + imagePatchDescriptorVisitor, priorityMap, &priorityFunction, patch_half_width, + boundaryStatusMap); InitializePriority(mask, boundaryNodeQueue, priorityMap, &priorityFunction, boundaryStatusMap); @@ -186,7 +190,7 @@ int main(int argc, char *argv[]) // Perform the inpainting inpainting_loop(graph, inpaintingVisitor, boundaryStatusMap, boundaryNodeQueue, linearSearchBest, patchInpainter); - HelpersOutput::WriteImage(image, outputFilename); + OutputHelpers::WriteImage(image, outputFilename); return EXIT_SUCCESS; } diff --git a/Concepts/DescriptorVisitorConcept.hpp b/Concepts/DescriptorVisitorConcept.hpp index 37c14d1..54464be 100644 --- a/Concepts/DescriptorVisitorConcept.hpp +++ b/Concepts/DescriptorVisitorConcept.hpp @@ -27,8 +27,8 @@ struct DescriptorVisitorConcept BOOST_CONCEPT_USAGE(DescriptorVisitorConcept) { - vis.initialize_vertex(u);// Function called on all vertices during the initialization phase. - vis.discover_vertex(u); // Function called when a live vertex is taken out of the priority-queue. + vis.InitializeVertex(u);// Function called on all vertices during the initialization phase. + vis.DiscoverVertex(u); // Function called when a live vertex is taken out of the priority-queue. }; }; diff --git a/Demos/CMakeLists.txt b/Demos/CMakeLists.txt index 19d3299..5a7a854 100644 --- a/Demos/CMakeLists.txt +++ b/Demos/CMakeLists.txt @@ -1,8 +1,8 @@ -add_executable(DemoBoundaryNormals DemoBoundaryNormals.cpp) -target_link_libraries(DemoBoundaryNormals PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) - -add_executable(DemoBoundaryNormals2 DemoBoundaryNormals2.cpp) -target_link_libraries(DemoBoundaryNormals2 PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${QT_LIBRARIES} libHelpers) +# add_executable(DemoBoundaryNormals DemoBoundaryNormals.cpp) +# target_link_libraries(DemoBoundaryNormals PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) +# +# add_executable(DemoBoundaryNormals2 DemoBoundaryNormals2.cpp) +# target_link_libraries(DemoBoundaryNormals2 PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${QT_LIBRARIES} libHelpers) # # add_executable(DemoClusterColors DemoClusterColors.cpp) # target_link_libraries(DemoClusterColors PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) @@ -16,42 +16,54 @@ target_link_libraries(DemoBoundaryNormals2 PatchBasedInpainting ${VTK_LIBRARIES} # add_executable(DemoColorImageByScore DemoColorImageByScore.cpp) # target_link_libraries(DemoColorImageByScore PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${QT_LIBRARIES}) -add_executable(DemoCreateImage DemoCreateImage.cpp) -target_link_libraries(DemoCreateImage PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) +# add_executable(DemoCreateImage DemoCreateImage.cpp) +# target_link_libraries(DemoCreateImage PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) # add_executable(DemoCreateMask DemoCreateMask.cpp) # target_link_libraries(DemoCreateMask PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) -add_executable(DemoDerivatives DemoDerivatives.cpp) -target_link_libraries(DemoDerivatives PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) - -add_executable(DemoErroneousGradient DemoErroneousGradient.cpp) -target_link_libraries(DemoErroneousGradient PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} libHelpers) - -add_executable(DemoFindPixelAcrossHole DemoFindPixelAcrossHole.cpp) -target_link_libraries(DemoFindPixelAcrossHole PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} libHelpers) - -add_executable(DemoFollowIsophotesAcrossBoundary DemoFollowIsophotesAcrossBoundary.cpp ${ROOT_SOURCE_DIR}/ImageProcessing/MaskOperations.cpp) -target_link_libraries(DemoFollowIsophotesAcrossBoundary PatchBasedInpainting -${VTK_LIBRARIES} ${ITK_LIBRARIES} ${QT_LIBRARIES} libHelpers) - -add_executable(DemoGradient DemoGradient.cpp) -target_link_libraries(DemoGradient PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${QT_LIBRARIES} libHelpers) - -add_executable(DemoInnerOuterBoundary DemoInnerOuterBoundary.cpp) -target_link_libraries(DemoInnerOuterBoundary PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) - -add_executable(DemoIsophotes DemoIsophotes.cpp ${ROOT_SOURCE_DIR}/ImageProcessing/MaskOperations.cpp) -target_link_libraries(DemoIsophotes PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${QT_LIBRARIES} libHelpers) - -add_executable(DemoPatchDifference DemoPatchDifference.cpp) -target_link_libraries(DemoPatchDifference PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} libHelpers) +# add_executable(DemoDerivatives DemoDerivatives.cpp) +# target_link_libraries(DemoDerivatives PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) +# +# add_executable(DemoErroneousGradient DemoErroneousGradient.cpp) +# target_link_libraries(DemoErroneousGradient PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} libHelpers) +# +# add_executable(DemoFindPixelAcrossHole DemoFindPixelAcrossHole.cpp) +# target_link_libraries(DemoFindPixelAcrossHole PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} libHelpers) +# +# add_executable(DemoFollowIsophotesAcrossBoundary DemoFollowIsophotesAcrossBoundary.cpp +# ${ROOT_SOURCE_DIR}/ImageProcessing/MaskOperations.cpp) +# target_link_libraries(DemoFollowIsophotesAcrossBoundary PatchBasedInpainting +# ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${QT_LIBRARIES} libHelpers) -add_executable(DemoPatchImageDifference DemoPatchImageDifference.cpp) -target_link_libraries(DemoPatchImageDifference PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} libHelpers) +# add_executable(DemoGradient DemoGradient.cpp) +# target_link_libraries(DemoGradient PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${QT_LIBRARIES} libHelpers) +# +# add_executable(DemoInnerOuterBoundary DemoInnerOuterBoundary.cpp) +# target_link_libraries(DemoInnerOuterBoundary PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES}) +# +# add_executable(DemoIsophotes DemoIsophotes.cpp ${ROOT_SOURCE_DIR}/ImageProcessing/MaskOperations.cpp) +# target_link_libraries(DemoIsophotes PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${QT_LIBRARIES} libHelpers) +# +# add_executable(DemoPatchDifference DemoPatchDifference.cpp) +# target_link_libraries(DemoPatchDifference PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} libHelpers) +# +# add_executable(DemoPatchImageDifference DemoPatchImageDifference.cpp) +# target_link_libraries(DemoPatchImageDifference PatchBasedInpainting ${VTK_LIBRARIES} ${ITK_LIBRARIES} libHelpers) +# +# add_executable(DemoPatchSearchFunction DemoPatchSearchFunction.cpp) +# target_link_libraries(DemoPatchSearchFunction PatchBasedInpainting ${ITK_LIBRARIES} ${VTK_LIBRARIES} ${QT_LIBRARIES} libHelpers) +# +# add_executable(DemoSelfPatchCompare DemoSelfPatchCompare.cpp) +# target_link_libraries(DemoSelfPatchCompare PatchBasedInpainting ${ITK_LIBRARIES} ${VTK_LIBRARIES} ${QT_LIBRARIES} libHelpers) -add_executable(DemoPatchSearchFunction DemoPatchSearchFunction.cpp) -target_link_libraries(DemoPatchSearchFunction PatchBasedInpainting ${ITK_LIBRARIES} ${VTK_LIBRARIES} ${QT_LIBRARIES} libHelpers) +add_executable(DemoBadPatchComparison DemoBadPatchComparison.cpp) +target_link_libraries(DemoBadPatchComparison PatchBasedInpainting ${ITK_LIBRARIES} ${VTK_LIBRARIES} ${QT_LIBRARIES} libHelpers) -add_executable(DemoSelfPatchCompare DemoSelfPatchCompare.cpp) -target_link_libraries(DemoSelfPatchCompare PatchBasedInpainting ${ITK_LIBRARIES} ${VTK_LIBRARIES} ${QT_LIBRARIES} libHelpers) +QT4_WRAP_UI(DemoBadPatchRealImageUISrcs ${ROOT_SOURCE_DIR}/Interactive/TopPatchesDialog.ui) +QT4_WRAP_CPP(DemoBadPatchRealImageMOCSrcs ${ROOT_SOURCE_DIR}/Interactive/TopPatchesDialog.h + ${ROOT_SOURCE_DIR}/Interactive/Delegates/PixmapDelegate.h) +add_executable(DemoBadPatchRealImage DemoBadPatchRealImage.cpp +${ROOT_SOURCE_DIR}/Interactive/Delegates/PixmapDelegate.cpp +${DemoBadPatchRealImageUISrcs} ${DemoBadPatchRealImageMOCSrcs}) +target_link_libraries(DemoBadPatchRealImage PatchBasedInpainting ${ITK_LIBRARIES} ${VTK_LIBRARIES} ${QT_LIBRARIES} libHelpers) diff --git a/Demos/DemoBadPatchComparison.cpp b/Demos/DemoBadPatchComparison.cpp index 9bac745..724340c 100644 --- a/Demos/DemoBadPatchComparison.cpp +++ b/Demos/DemoBadPatchComparison.cpp @@ -71,8 +71,9 @@ int main(int argc, char *argv[]) ++shiftedImageIterator; } - ImageType::PixelType averagePixel = ITKHelpers::AverageInRegion(noisyImage, noisyImage->GetLargestPossibleRegion()); - ITKHelpers::SetRegionToConstant(averageImage, averageImage->GetLargestPossibleRegion(), averagePixel); + ImageType::PixelType averagePixel = ITKHelpers::AverageInRegion(noisyImage.GetPointer(), + noisyImage->GetLargestPossibleRegion()); + ITKHelpers::SetRegionToConstant(averageImage.GetPointer(), averageImage->GetLargestPossibleRegion(), averagePixel); return EXIT_SUCCESS; } diff --git a/Demos/DemoBadPatchRealImage.cpp b/Demos/DemoBadPatchRealImage.cpp index 5bc8034..9cd2aea 100644 --- a/Demos/DemoBadPatchRealImage.cpp +++ b/Demos/DemoBadPatchRealImage.cpp @@ -37,6 +37,77 @@ #include "itkImage.h" #include "itkImageFileReader.h" +typedef itk::VectorImage ImageType; + +struct DemoDriver +{ + + typedef boost::grid_graph<2> VertexListGraphType; + typedef boost::graph_traits::vertex_descriptor VertexDescriptorType; + typedef ImagePatchPixelDescriptor ImagePatchPixelDescriptorType; + typedef boost::property_map::const_type IndexMapType; + typedef boost::vector_property_map ImagePatchDescriptorMapType; + typedef ImagePatchDescriptorVisitor VisitorType; + typedef LinearSearchKNNProperty > KNNSearchType; + VertexListGraphType* graph; + + unsigned int PatchRadius; + + ImageType* Image; + Mask* MaskImage; + + VisitorType* Visitor; + + KNNSearchType* KNNSearch; + + ImagePatchDescriptorMapType* ImagePatchDescriptorMap; + + DemoDriver(ImageType* const image, Mask* const mask) : graph(NULL), PatchRadius(15), Image(image), MaskImage(mask) + { + boost::array graphSideLengths = { { image->GetLargestPossibleRegion().GetSize()[0], + image->GetLargestPossibleRegion().GetSize()[1] } }; + //VertexListGraphType graph(graphSideLengths); + graph = new VertexListGraphType(graphSideLengths); + + // Get the index map + IndexMapType indexMap(get(boost::vertex_index, *graph)); + + // Create the descriptor map. This is where the data for each pixel is stored. + ImagePatchDescriptorMap = new ImagePatchDescriptorMapType(num_vertices(*graph), indexMap); + + Visitor = new VisitorType(Image, MaskImage, *ImagePatchDescriptorMap, PatchRadius); + + InitializeFromMaskImage(MaskImage, Visitor); + + // Create the nearest neighbor finders + KNNSearch = new KNNSearchType(*ImagePatchDescriptorMap, 1000); + } + + void DisplayTopPatches(VertexDescriptorType targetNode) + { + Visitor->DiscoverVertex(targetNode); + + std::vector bestSourceNodes; + typename boost::graph_traits::vertex_iterator vi,vi_end; + tie(vi,vi_end) = vertices(*graph); + (*KNNSearch)(vi, vi_end, targetNode, bestSourceNodes); + + std::cout << "There are " << bestSourceNodes.size() << " bestSourceNodes." << std::endl; + + TopPatchesDialog* topPatchesDialog = new TopPatchesDialog(Image, MaskImage, PatchRadius); + topPatchesDialog->SetQueryNode(targetNode); + topPatchesDialog->SetSourceNodes(bestSourceNodes); + //topPatchesDialog->exec(); + topPatchesDialog->show(); + + // Return the node to an invalid state + ImagePatchPixelDescriptorType& descriptor = get(*ImagePatchDescriptorMap, targetNode); + descriptor.SetStatus(PixelDescriptor::INVALID); + } + +}; + int main(int argc, char *argv[]) { if(argc != 3) @@ -48,7 +119,6 @@ int main(int argc, char *argv[]) std::string imageFileName = argv[1]; std::string maskFileName = argv[2]; - typedef itk::VectorImage ImageType; typedef itk::ImageFileReader ImageReaderType; ImageReaderType::Pointer imageReader = ImageReaderType::New(); imageReader->SetFileName(imageFileName); @@ -62,60 +132,23 @@ int main(int argc, char *argv[]) maskReader->SetFileName(maskFileName); maskReader->Update(); - itk::Index<2> centerGood = {{503,156}}; - itk::Index<2> centerBad = {{503,146}}; - - const unsigned int patchRadius = 15; - itk::ImageRegion<2> regionGood = ITKHelpers::GetRegionInRadiusAroundPixel(centerGood, patchRadius); - itk::ImageRegion<2> regionBad = ITKHelpers::GetRegionInRadiusAroundPixel(centerBad, patchRadius); - - - typedef ImagePatchPixelDescriptor ImagePatchPixelDescriptorType; - - // Create the graph - typedef boost::grid_graph<2> VertexListGraphType; - boost::array graphSideLengths = { { imageReader->GetOutput()->GetLargestPossibleRegion().GetSize()[0], - imageReader->GetOutput()->GetLargestPossibleRegion().GetSize()[1] } }; - VertexListGraphType graph(graphSideLengths); - typedef boost::graph_traits::vertex_descriptor VertexDescriptorType; - - // Get the index map - typedef boost::property_map::const_type IndexMapType; - IndexMapType indexMap(get(boost::vertex_index, graph)); - - // Create the descriptor map. This is where the data for each pixel is stored. - typedef boost::vector_property_map ImagePatchDescriptorMapType; - ImagePatchDescriptorMapType imagePatchDescriptorMap(num_vertices(graph), indexMap); - - typedef ImagePatchDescriptorVisitor VisitorType; - VisitorType visitor(imageReader->GetOutput(), maskReader->GetOutput(), imagePatchDescriptorMap, patchRadius); - - InitializeFromMaskImage(maskReader->GetOutput(), &visitor); - - // Create the nearest neighbor finders - typedef LinearSearchKNNProperty > KNNSearchType; - KNNSearchType knnSearch(imagePatchDescriptorMap, 100); - - VertexDescriptorType goodTargetNode = Helpers::ConvertFrom >(centerGood); - //VertexDescriptorType badTargetNode = Helpers::ConvertFrom >(centerBad); - - VertexDescriptorType targetNode = goodTargetNode; + // Setup the GUI system + QApplication app( argc, argv ); - std::vector bestSourceNodes; - typename boost::graph_traits::vertex_iterator vi,vi_end; - tie(vi,vi_end) = vertices(graph); - knnSearch(vi, vi_end, goodTargetNode, bestSourceNodes); + DemoDriver demoDriver(imageReader->GetOutput(), maskReader->GetOutput()); - std::cout << "There are " << bestSourceNodes.size() << " bestSourceNodes." << std::endl; + itk::Index<2> centerGood = {{503,156}}; + DemoDriver::VertexDescriptorType goodTargetNode = Helpers::ConvertFrom >(centerGood); + demoDriver.DisplayTopPatches(goodTargetNode); - // Setup the GUI system - QApplication app( argc, argv ); + // itk::Index<2> centerBad = {{503,146}}; // The top 1000 matches to this patch are completely wrong + itk::Index<2> centerBad = {{503,147}}; + DemoDriver::VertexDescriptorType badTargetNode = Helpers::ConvertFrom >(centerBad); + demoDriver.DisplayTopPatches(badTargetNode); - TopPatchesDialog topPatchesDialog(imageReader->GetOutput(), maskReader->GetOutput(), patchRadius); - topPatchesDialog.SetQueryNode(targetNode); - topPatchesDialog.SetSourceNodes(bestSourceNodes); - topPatchesDialog.exec(); + app.exec(); return EXIT_SUCCESS; } diff --git a/DifferenceFunctions/ImagePatchDifference.hpp b/DifferenceFunctions/ImagePatchDifference.hpp index fbe0dc1..ac374d3 100644 --- a/DifferenceFunctions/ImagePatchDifference.hpp +++ b/DifferenceFunctions/ImagePatchDifference.hpp @@ -45,6 +45,7 @@ struct ImagePatchDifference float totalDifference = 0.0f; + // If both nodes are source nodes, compare them fully. if(a.GetStatus() == ImagePatchType::SOURCE_NODE && b.GetStatus() == ImagePatchType::SOURCE_NODE) { itk::Offset<2> offsetAToB = b.GetCorner() - a.GetCorner(); @@ -70,6 +71,7 @@ struct ImagePatchDifference ++patchAIterator; } } + // If one of the nodes is a target node, only compare in it's list of valid offset pixels. else if(a.GetStatus() == ImagePatchType::TARGET_NODE || b.GetStatus() == ImagePatchType::TARGET_NODE) { const std::vector >* validOffsets; diff --git a/Helpers/ITKHelpers.hxx b/Helpers/ITKHelpers.hxx index 97d9a34..b49e577 100644 --- a/Helpers/ITKHelpers.hxx +++ b/Helpers/ITKHelpers.hxx @@ -718,7 +718,7 @@ typename TImage::PixelType AverageOfPixelsAtIndices(const TImage* const image, c template typename TImage::PixelType AverageInRegion(const TImage* const image, const itk::ImageRegion<2>& region) { - typename itk::ImageRegionIterator imageIterator(image, region); + typename itk::ImageRegionConstIterator imageIterator(image, region); std::vector pixels; while(!imageIterator.IsAtEnd()) { diff --git a/Interactive/TopPatchesDialog.h b/Interactive/TopPatchesDialog.h index 947356c..66bceca 100644 --- a/Interactive/TopPatchesDialog.h +++ b/Interactive/TopPatchesDialog.h @@ -37,7 +37,9 @@ Q_OBJECT public slots: + /** Ideally this would be templated on the node type, but since it is a slot it cannot be templated. */ virtual void SetSourceNodes(const std::vector& sourceNodes) = 0; + virtual void SetQueryNode(const Node& queryNode) = 0; virtual void slot_Selected(const QModelIndex & index) = 0; }; @@ -78,6 +80,9 @@ class TopPatchesDialog : public TopPatchesDialogParent /** Set the source nodes from which the user can choose. */ void SetSourceNodes(const std::vector& nodes); + template + void SetSourceNodes(const std::vector& sourceNodes); + /** Set the query node that the user will choose the best match to. */ void SetQueryNode(const Node& node); diff --git a/Interactive/TopPatchesDialog.hpp b/Interactive/TopPatchesDialog.hpp index cf2fb4d..e2467a0 100644 --- a/Interactive/TopPatchesDialog.hpp +++ b/Interactive/TopPatchesDialog.hpp @@ -50,6 +50,19 @@ void TopPatchesDialog::SetSourceNodes(const std::vector& nodes) this->PatchesModel->SetNodes(nodes); } +template +template +void TopPatchesDialog::SetSourceNodes(const std::vector& sourceNodes) +{ + std::vector nodes; + for(unsigned int i = 0; i < sourceNodes.size(); ++i) + { + Node node = Helpers::ConvertFrom(sourceNodes[i]); + nodes.push_back(node); + } + SetSourceNodes(nodes); +} + template void TopPatchesDialog::SetQueryNode(const Node& queryNode) { diff --git a/Node.h b/Node.h index aa03e16..5824ab8 100644 --- a/Node.h +++ b/Node.h @@ -60,6 +60,11 @@ class Node return coord[component]; } + int& operator[](const unsigned int& component) + { + return coord[component]; + } + template void CreateFromObject(const T& object) { diff --git a/Visitors/DescriptorVisitors/CompositeDescriptorVisitor.hpp b/Visitors/DescriptorVisitors/CompositeDescriptorVisitor.hpp index 28fbfeb..5467fe6 100644 --- a/Visitors/DescriptorVisitors/CompositeDescriptorVisitor.hpp +++ b/Visitors/DescriptorVisitors/CompositeDescriptorVisitor.hpp @@ -14,7 +14,7 @@ struct CompositeDescriptorVisitor { typedef typename boost::graph_traits::vertex_descriptor VertexDescriptorType; - void initialize_vertex(VertexDescriptorType v) const + void InitializeVertex(VertexDescriptorType v) const { for(unsigned int visitorId = 0; visitorId < Visitors.size(); ++visitorId) { @@ -22,7 +22,7 @@ struct CompositeDescriptorVisitor } }; - void discover_vertex(VertexDescriptorType v) const + void DiscoverVertex(VertexDescriptorType v) const { for(unsigned int visitorId = 0; visitorId < Visitors.size(); ++visitorId) { diff --git a/Visitors/DescriptorVisitors/DescriptorVisitorParent.h b/Visitors/DescriptorVisitors/DescriptorVisitorParent.h index d4277c5..18b40f2 100644 --- a/Visitors/DescriptorVisitors/DescriptorVisitorParent.h +++ b/Visitors/DescriptorVisitors/DescriptorVisitorParent.h @@ -14,9 +14,9 @@ struct DescriptorVisitorParent { typedef typename boost::graph_traits::vertex_descriptor VertexDescriptorType; - virtual void initialize_vertex(VertexDescriptorType v) const = 0; + virtual void InitializeVertex(VertexDescriptorType v) const = 0; - virtual void discover_vertex(VertexDescriptorType v) const = 0; + virtual void DiscoverVertex(VertexDescriptorType v) const = 0; }; // DescriptorVisitorParent diff --git a/Visitors/DescriptorVisitors/ImagePatchDescriptorVisitor.hpp b/Visitors/DescriptorVisitors/ImagePatchDescriptorVisitor.hpp index ef29b96..5506118 100644 --- a/Visitors/DescriptorVisitors/ImagePatchDescriptorVisitor.hpp +++ b/Visitors/DescriptorVisitors/ImagePatchDescriptorVisitor.hpp @@ -39,13 +39,11 @@ struct ImagePatchDescriptorVisitor : public DescriptorVisitorParent { } - void initialize_vertex(VertexDescriptorType v) const + void InitializeVertex(VertexDescriptorType v) const { //std::cout << "Initializing " << v[0] << " " << v[1] << std::endl; // Create the patch object and associate with the node - itk::Index<2> index; - index[0] = v[0]; - index[1] = v[1]; + itk::Index<2> index = ITKHelpers::CreateIndex(v); itk::ImageRegion<2> region = ITKHelpers::GetRegionInRadiusAroundPixel(index, HalfWidth); @@ -60,7 +58,7 @@ struct ImagePatchDescriptorVisitor : public DescriptorVisitorParent // } }; - void discover_vertex(VertexDescriptorType v) const + void DiscoverVertex(VertexDescriptorType v) const { itk::Index<2> index = {{v[0], v[1]}}; itk::ImageRegion<2> region = ITKHelpers::GetRegionInRadiusAroundPixel(index, HalfWidth); diff --git a/Visitors/InpaintingVisitor.hpp b/Visitors/InpaintingVisitor.hpp index cefd1e1..a4d0139 100644 --- a/Visitors/InpaintingVisitor.hpp +++ b/Visitors/InpaintingVisitor.hpp @@ -61,12 +61,12 @@ struct InpaintingVisitor : public InpaintingVisitorParent void InitializeVertex(VertexDescriptorType v) const { - DescriptorVisitor.initialize_vertex(v); + DescriptorVisitor.InitializeVertex(v); }; void DiscoverVertex(VertexDescriptorType v) const { - DescriptorVisitor.discover_vertex(v); + DescriptorVisitor.DiscoverVertex(v); }; void PotentialMatchMade(VertexDescriptorType target, VertexDescriptorType source)