zqpei / patchmatch_inpainting Goto Github PK
View Code? Open in Web Editor NEWImplementation of PatchMatch for image inpainting in cpp
License: Other
Implementation of PatchMatch for image inpainting in cpp
License: Other
@zvezdochiot
The memory will overflow if proceeding mounts of images in one program.
How to get this:
First prepare a large test set of 1000 images or more. For simpility, just copy the existing test images for 400 times, the same to the masks. Rename then as image_00001.png
, image_00002.png
, etc.
Replace the main
function as what I did at the very beginning. It was tested on 12000 images with 6 group of masks. You may need modify the code below a little bit to run on your test images properly.
If you find your memory usage growing continuously, that is the implicit problem hidden in the process
function which will cause segmentation fault.
int main(int argc, char** argv) {
char image_path[100];
char mask_path[100];
char masked_path[100];
char output_path[100];
double psnr_mean[6] = {0,};
double ssim_mean[6] = {0,};
double time_mean[6] = {0,};
for(int i=0;i<6;++i){
double psnr_total = 0.0;
double ssim_total = 0.0;
double time_total = 0.0;
for(int j=i*2000;j<(i+1)*2000;++j){
sprintf(image_path, "../image_files/inpainting/image/image_%05d.png", j);
sprintf(mask_path, "../image_files/inpainting/mask/mask_%05d.png", j);
sprintf(masked_path, "../image_files/inpainting/masked_image/masked_image_%05d.png", j);
sprintf(output_path, "../image_files/inpainting/output/output_%05d.png", j);
process(image_path, mask_path, output_path, &psnr_total, &ssim_total, &time_total);
}
psnr_mean[i] = psnr_total/2000.0;
ssim_mean[i] = ssim_total/2000.0;
time_mean[i] = time_total/2000.0;
printf("[%02d%% - %02d%%] average psnr: %lf\taverage ssim: %lf\taverage time: %lf\n", i*10, (i+1)*10, psnr_mean[i], ssim_mean[i], time_mean[i]);
FILE * fp = fopen("../image_files/inpainting/result.txt", "a");
fprintf(fp, "[%02d%% - %02d%%] average psnr: %lf\taverage ssim: %lf\taverage time: %lf\n", i*10, (i+1)*10, psnr_mean[i], ssim_mean[i], time_mean[i]);
fclose(fp);
}
for(int i=0;i<6;++i){
printf("[%02d%% - %02d%%] average psnr: %lf\taverage ssim: %lf\taverage time: %lf\n", i*10, (i+1)*10, psnr_mean[i], ssim_mean[i], time_mean[i]);
}
return 0;
}
patchmatch_inpainting/CMakeLists.txt
Lines 27 to 28 in 53c3610
main
? Maybe inpaintcv
?
patchmatch_inpainting/source/main.cpp
Lines 63 to 65 in 0bea9c6
Maybe?:
int ** mask = (int **)calloc(int(height), sizeof(int*));
for (int i = 0; i < height; i++)
mask[i] = (int *)calloc(int(width), sizeof(int));
See:
patchmatch_inpainting/source/main.cpp
Lines 127 to 130 in 0bea9c6
Hello @ZQPei and @zvezdochiot Thank you for your work!
I wonder if is it possible to improve results of deep learning approach with patch-match algorithm. It seems to me neural network should better understand the content of a gap in image. Unfortunately methods that we have tried output quite blurred texture. In contrast patch match is good at giving sharp textures.
How do you think will patchmatch work on neural network output? And where should I start in order to modify the code to take not only neighbour pixels but also pixels under the mask?
Here are some examples where neural network could improve in-painting results:
left – original; center – neural network; right – patchmatch (this repo);
notice border of column
deformation of road
smth brown in the water and creepy copy of the guy's hand
Thank you in advance for any help and thoughts!
Such as iteration and patch size, as what's done at https://yuantinghsieh.github.io/Image_Completion/ (but in matlab)
$ g++ --version
g++ (Debian 4.7.2-5) 4.7.2
All works.
patchmatch_inpainting/source/main.cpp
Lines 137 to 163 in 53c3610
Maybe?:
int main(int argc, char** argv)
{
double psnr_total = 0.0;
double ssim_total = 0.0;
double time_total = 0.0;
if (argc != 4)
{
printf("Usage: %s input.png mask.png output.png", argv[0]);
}
else
{
process(argv[1], argv[2], argv[3], &psnr_total, &ssim_total, &time_total);
printf("average psnr: %lf\taverage ssim: %lf\taverage time: %lf\n", psnr_total, ssim_total, time_total);
}
return 0;
}
See also: #2
PS: fresh eys.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.