Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some fixes.

  • Loading branch information...
commit 1cfa6c2342be57754a710c653d01144ec3cbec78 1 parent 0992362
@daviddoria authored
View
4 BDSInpaintingDemo.cpp
@@ -42,7 +42,9 @@ int main(int argc, char*argv[])
bdsInpainting.SetImage(imageReader->GetOutput());
bdsInpainting.SetMask(mask);
//bdsInpainting.SetResolutionLevels(1);
- bdsInpainting.SetResolutionLevels(4);
+ bdsInpainting.SetResolutionLevels(2);
+ //bdsInpainting.SetResolutionLevels(3);
+ //bdsInpainting.SetResolutionLevels(4);
//bdsInpainting.SetResolutionLevels(25);
bdsInpainting.SetIterations(4);
bdsInpainting.SetPatchRadius(10);
View
6 CMakeLists.txt
@@ -8,16 +8,18 @@ INCLUDE(${USE_ITK_FILE})
add_subdirectory(Mask)
+# Patch match
add_library(PatchMatch PatchMatch.cpp)
target_link_libraries(PatchMatch Mask)
-ADD_EXECUTABLE(PatchMatchDemo PatchMatchDemo.cpp PatchMatch.cpp)
+ADD_EXECUTABLE(PatchMatchDemo PatchMatchDemo.cpp)
TARGET_LINK_LIBRARIES(PatchMatchDemo PatchMatch)
ADD_EXECUTABLE(PatchMatchInitDemo PatchMatchInitDemo.cpp)
TARGET_LINK_LIBRARIES(PatchMatchInitDemo PatchMatch)
-add_library(BDSInpainting PatchMatch.cpp BDSInpainting.cpp)
+# Bidirectional similarity inpainting
+add_library(BDSInpainting BDSInpainting.cpp)
target_link_libraries(BDSInpainting PatchMatch)
ADD_EXECUTABLE(BDSInpaintingDemo BDSInpaintingDemo.cpp)
2  Mask
@@ -1 +1 @@
-Subproject commit 993d8beb1cd9defb1a69e55762c1f79ef4a673d6
+Subproject commit 43c47fae46e95b9d661ef247086601bcc8521dfc
View
13 PatchMatch.cpp
@@ -28,8 +28,6 @@ void PatchMatch::Compute(PMImageType* const initialization)
}
else
{
- this->Output->SetRegions(this->Image->GetLargestPossibleRegion());
- this->Output->Allocate();
//RandomInit();
BoundaryInit();
}
@@ -249,6 +247,8 @@ void PatchMatch::Compute(PMImageType* const initialization)
Match currentMatch = outputIterator.Get();
unsigned int radius = std::max(width, height);
+ //radius /= 2; // Only search half of the image
+ radius /= 8; // Only search a small window
// Search an exponentially smaller window each time through the loop
itk::Index<2> searchRegionCenter = ITKHelpers::GetRegionCenter(outputIterator.Get().Region);
@@ -408,6 +408,7 @@ void PatchMatch::BoundaryInit()
Mask::BoundaryImageType::Pointer boundaryImage = Mask::BoundaryImageType::New();
unsigned char outputBoundaryPixelValue = 255;
expandedMask->FindBoundary(boundaryImage.GetPointer(), Mask::VALID, outputBoundaryPixelValue);
+ ITKHelpers::WriteImage(boundaryImage.GetPointer(), "ExpandedBoundary.png");
// Get the boundary pixels
std::vector<itk::Index<2> > boundaryIndices = ITKHelpers::GetPixelsWithValue(boundaryImage.GetPointer(), outputBoundaryPixelValue);
@@ -428,12 +429,13 @@ void PatchMatch::BoundaryInit()
// Construct the current region
itk::Index<2> currentIndex = outputIterator.GetIndex();
- if(this->SourceMask->IsHole(currentIndex))
+ if(expandedMask->IsHole(currentIndex))
{
itk::ImageRegion<2> currentRegion = ITKHelpers::GetRegionInRadiusAroundPixel(currentIndex, this->PatchRadius);
// Find the nearest valid boundary patch
- itk::Index<2> closestBoundaryPatchCenter = boundaryIndices[ITKHelpers::ClosestPixel(boundaryIndices, currentIndex)];
+ unsigned int closestIndexId = ITKHelpers::ClosestIndexId(boundaryIndices, currentIndex);
+ itk::Index<2> closestBoundaryPatchCenter = boundaryIndices[closestIndexId];
itk::ImageRegion<2> closestBoundaryPatchRegion = ITKHelpers::GetRegionInRadiusAroundPixel(closestBoundaryPatchCenter,
this->PatchRadius);
@@ -506,6 +508,9 @@ void PatchMatch::SetPatchRadius(const unsigned int patchRadius)
void PatchMatch::SetImage(ImageType* const image)
{
ITKHelpers::DeepCopy(image, this->Image.GetPointer());
+
+ this->Output->SetRegions(this->Image->GetLargestPossibleRegion());
+ this->Output->Allocate();
}
void PatchMatch::SetSourceMask(Mask* const mask)
View
2  PatchMatch.h
@@ -46,7 +46,7 @@ class PatchMatch
/** Set the mask indicating where to compute the NNField. */
void SetTargetMask(Mask* const mask);
- /** Get the patch centers image from the nearest neighbor field struct.. */
+ /** Get an image where the channels are (x component, y component, score) from the nearest neighbor field struct. */
static void GetPatchCentersImage(PMImageType* const pmImage, itk::VectorImage<float, 2>* const output);
/** Set the nearest neighbor field to exactly iself in the valid region, and random values in the hole region. */
View
18 PatchMatchInitDemo.cpp
@@ -46,14 +46,22 @@ int main(int argc, char*argv[])
patchMatch.SetIterations(10);
patchMatch.SetPatchRadius(3);
+ PatchMatch::VectorImageType::Pointer output = PatchMatch::VectorImageType::New();
+
+ {
+ std::cout << "Starting randomInit..." << std::endl;
patchMatch.RandomInit();
- PatchMatch::VectorImageType::Pointer temp = PatchMatch::VectorImageType::New();
- PatchMatch::GetPatchCentersImage(patchMatch.GetOutput(), temp);
- ITKHelpers::WriteImage(temp.GetPointer(), "randomInit.mha");
+ PatchMatch::GetPatchCentersImage(patchMatch.GetOutput(), output);
+ ITKHelpers::WriteImage(output.GetPointer(), "randomInit.mha");
+ }
+
+ {
+ std::cout << "Starting boundaryInit..." << std::endl;
patchMatch.BoundaryInit();
- PatchMatch::GetPatchCentersImage(patchMatch.GetOutput(), temp);
- ITKHelpers::WriteImage(temp.GetPointer(), "boundaryInit.mha");
+ PatchMatch::GetPatchCentersImage(patchMatch.GetOutput(), output);
+ ITKHelpers::WriteImage(output.GetPointer(), "boundaryInit.mha");
+ }
return EXIT_SUCCESS;
}
Please sign in to comment.
Something went wrong with that request. Please try again.