The response has been limited to 50k tokens of the smallest files in the repo. You can remove this limitation by removing the max tokens filter.
├── 3rdparty
    ├── colorspace
    │   ├── colorcalc.c
    │   ├── colorspace.c
    │   ├── colorspace.h
    │   ├── colorspace.html
    │   ├── colorspace.m
    │   ├── colorspace_01.jpg
    │   ├── colorspace_02.jpg
    │   ├── colorspace_03.jpg
    │   ├── colorspace_ciedemo.m
    │   ├── colorspace_demo.m
    │   └── colorspace_test.m
    ├── guided_filter
    │   ├── boxfilter.m
    │   ├── example_enhancement.m
    │   ├── example_feathering.m
    │   ├── example_flash.m
    │   ├── example_smoothing.m
    │   ├── guidedfilter.m
    │   ├── guidedfilter_color.m
    │   ├── img_enhancement
    │   │   └── tulips.bmp
    │   ├── img_feathering
    │   │   ├── toy-mask.bmp
    │   │   └── toy.bmp
    │   ├── img_flash
    │   │   ├── cave-flash.bmp
    │   │   └── cave-noflash.bmp
    │   ├── img_smoothing
    │   │   └── cat.bmp
    │   └── readme.txt
    └── patchmatch-2.0
    │   ├── allegro_emu.cpp
    │   ├── allegro_emu.h
    │   ├── build_mac.sh
    │   ├── build_unix.sh
    │   ├── build_windows.bat
    │   ├── console_test_descriptor_mex.m
    │   ├── console_test_knn.m
    │   ├── console_test_mex.m
    │   ├── console_test_rot_scale.m
    │   ├── gen_all.m
    │   ├── knn.cpp
    │   ├── knn.h
    │   ├── load_vgg_features.m
    │   ├── log.txt
    │   ├── mex.sln
    │   ├── mex.v12.suo
    │   ├── mexutil.cpp
    │   ├── mexutil.h
    │   ├── neural_patchmatch.m
    │   ├── nn.cpp
    │   ├── nn.h
    │   ├── nnmex.cpp
    │   ├── nnmex.m
    │   ├── nnmex.mexa64
    │   ├── nnmex.mexw64
    │   ├── patch.cpp
    │   ├── patch.h
    │   ├── pm_minimal.cpp
    │   ├── readme.txt
    │   ├── simnn.cpp
    │   ├── simnn.h
    │   ├── simpatch.h
    │   ├── test_descriptor_mex.m
    │   ├── test_knn.m
    │   ├── test_mex.m
    │   ├── test_rot_scale.m
    │   ├── vecnn.cpp
    │   ├── vecnn.h
    │   ├── vecpatch.h
    │   ├── votemex.cpp
    │   ├── votemex.m
    │   ├── votemex.mexa64
    │   ├── votemex.mexw64
    │   └── writeim.m
├── README.md
├── README2.md
├── cuda_utils.cu
├── data
    ├── 0_c_mask.jpg
    ├── 0_c_mask_dilated.jpg
    ├── 0_naive.jpg
    ├── 0_target.jpg
    ├── 10_c_mask.jpg
    ├── 10_c_mask_dilated.jpg
    ├── 10_naive.jpg
    ├── 10_target.jpg
    ├── 11_c_mask.jpg
    ├── 11_c_mask_dilated.jpg
    ├── 11_naive.jpg
    ├── 11_target.jpg
    ├── 12_c_mask.jpg
    ├── 12_c_mask_dilated.jpg
    ├── 12_naive.jpg
    ├── 12_target.jpg
    ├── 13_c_mask.jpg
    ├── 13_c_mask_dilated.jpg
    ├── 13_naive.jpg
    ├── 13_target.jpg
    ├── 14_c_mask.jpg
    ├── 14_c_mask_dilated.jpg
    ├── 14_naive.jpg
    ├── 14_target.jpg
    ├── 15_c_mask.jpg
    ├── 15_c_mask_dilated.jpg
    ├── 15_naive.jpg
    ├── 15_target.jpg
    ├── 16_c_mask.jpg
    ├── 16_c_mask_dilated.jpg
    ├── 16_naive.jpg
    ├── 16_target.jpg
    ├── 17_c_mask.jpg
    ├── 17_c_mask_dilated.jpg
    ├── 17_naive.jpg
    ├── 17_target.jpg
    ├── 18_c_mask.jpg
    ├── 18_c_mask_dilated.jpg
    ├── 18_naive.jpg
    ├── 18_target.jpg
    ├── 19_c_mask.jpg
    ├── 19_c_mask_dilated.jpg
    ├── 19_naive.jpg
    ├── 19_target.jpg
    ├── 1_c_mask.jpg
    ├── 1_c_mask_dilated.jpg
    ├── 1_naive.jpg
    ├── 1_target.jpg
    ├── 20_c_mask.jpg
    ├── 20_c_mask_dilated.jpg
    ├── 20_naive.jpg
    ├── 20_target.jpg
    ├── 21_c_mask.jpg
    ├── 21_c_mask_dilated.jpg
    ├── 21_naive.jpg
    ├── 21_target.jpg
    ├── 22_c_mask.jpg
    ├── 22_c_mask_dilated.jpg
    ├── 22_naive.jpg
    ├── 22_target.jpg
    ├── 23_c_mask.jpg
    ├── 23_c_mask_dilated.jpg
    ├── 23_naive.jpg
    ├── 23_target.jpg
    ├── 24_c_mask.jpg
    ├── 24_c_mask_dilated.jpg
    ├── 24_naive.jpg
    ├── 24_target.jpg
    ├── 25_c_mask.jpg
    ├── 25_c_mask_dilated.jpg
    ├── 25_naive.jpg
    ├── 25_target.jpg
    ├── 26_c_mask.jpg
    ├── 26_c_mask_dilated.jpg
    ├── 26_naive.jpg
    ├── 26_target.jpg
    ├── 27_c_mask.jpg
    ├── 27_c_mask_dilated.jpg
    ├── 27_naive.jpg
    ├── 27_target.jpg
    ├── 28_c_mask.jpg
    ├── 28_c_mask_dilated.jpg
    ├── 28_naive.jpg
    ├── 28_target.jpg
    ├── 29_c_mask.jpg
    ├── 29_c_mask_dilated.jpg
    ├── 29_naive.jpg
    ├── 29_target.jpg
    ├── 2_c_mask.jpg
    ├── 2_c_mask_dilated.jpg
    ├── 2_naive.jpg
    ├── 2_target.jpg
    ├── 30_c_mask.jpg
    ├── 30_c_mask_dilated.jpg
    ├── 30_naive.jpg
    ├── 30_target.jpg
    ├── 31_c_mask.jpg
    ├── 31_c_mask_dilated.jpg
    ├── 31_naive.jpg
    ├── 31_target.jpg
    ├── 32_c_mask.jpg
    ├── 32_c_mask_dilated.jpg
    ├── 32_naive.jpg
    ├── 32_target.jpg
    ├── 33_c_mask.jpg
    ├── 33_c_mask_dilated.jpg
    ├── 33_naive.jpg
    ├── 33_target.jpg
    ├── 34_c_mask.jpg
    ├── 34_c_mask_dilated.jpg
    ├── 34_naive.jpg
    ├── 34_target.jpg
    ├── 35_target.jpg
    ├── 3_c_mask.jpg
    ├── 3_c_mask_dilated.jpg
    ├── 3_naive.jpg
    ├── 3_target.jpg
    ├── 4_c_mask.jpg
    ├── 4_c_mask_dilated.jpg
    ├── 4_naive.jpg
    ├── 4_target.jpg
    ├── 5_c_mask.jpg
    ├── 5_c_mask_dilated.jpg
    ├── 5_naive.jpg
    ├── 5_target.jpg
    ├── 6_c_mask.jpg
    ├── 6_c_mask_dilated.jpg
    ├── 6_naive.jpg
    ├── 6_target.jpg
    ├── 7_c_mask.jpg
    ├── 7_c_mask_dilated.jpg
    ├── 7_naive.jpg
    ├── 7_target.jpg
    ├── 8_c_mask.jpg
    ├── 8_c_mask_dilated.jpg
    ├── 8_naive.jpg
    ├── 8_target.jpg
    ├── 9_c_mask.jpg
    ├── 9_c_mask_dilated.jpg
    ├── 9_naive.jpg
    ├── 9_target.jpg
    └── wikiart_output.txt
├── dilate_mask.m
├── filt_cnn_artifact.m
├── gen_all.py
├── makefile
├── models
    └── download_models.sh
├── neural_gram.lua
├── neural_paint.lua
└── results
    ├── 0_final_res.png
    ├── 0_final_res2.png
    ├── 0_inter_res.jpg
    ├── 10_final_res.png
    ├── 10_final_res2.png
    ├── 10_inter_res.jpg
    ├── 11_final_res.png
    ├── 11_final_res2.png
    ├── 11_inter_res.jpg
    ├── 12_final_res.png
    ├── 12_final_res2.png
    ├── 12_inter_res.jpg
    ├── 13_final_res.png
    ├── 13_final_res2.png
    ├── 13_inter_res.jpg
    ├── 14_final_res.png
    ├── 14_final_res2.png
    ├── 14_inter_res.jpg
    ├── 15_final_res.png
    ├── 15_final_res2.png
    ├── 15_inter_res.jpg
    ├── 16_final_res.png
    ├── 16_final_res2.png
    ├── 16_inter_res.jpg
    ├── 17_final_res.png
    ├── 17_final_res2.png
    ├── 17_inter_res.jpg
    ├── 17_naive_sherlock.jpg
    ├── 17_result_sherlock.jpg
    ├── 18_final_res.png
    ├── 18_final_res2.png
    ├── 18_inter_res.jpg
    ├── 19_final_res.png
    ├── 19_final_res2.png
    ├── 19_inter_res.jpg
    ├── 1_final_res.png
    ├── 1_final_res2.png
    ├── 1_inter_res.jpg
    ├── 20_final_res.png
    ├── 20_final_res2.png
    ├── 20_inter_res.jpg
    ├── 21_final_res.png
    ├── 21_final_res2.png
    ├── 21_inter_res.jpg
    ├── 22_final_res.png
    ├── 22_final_res2.png
    ├── 22_inter_res.jpg
    ├── 23_final_res.png
    ├── 23_final_res2.png
    ├── 23_inter_res.jpg
    ├── 24_final_res.png
    ├── 24_final_res2.png
    ├── 24_inter_res.jpg
    ├── 25_final_res.png
    ├── 25_final_res2.png
    ├── 25_inter_res.jpg
    ├── 26_final_res.png
    ├── 26_final_res2.png
    ├── 26_inter_res.jpg
    ├── 27_final_res.png
    ├── 27_final_res2.png
    ├── 27_inter_res.jpg
    ├── 28_final_res.png
    ├── 28_final_res2.png
    ├── 28_inter_res.jpg
    ├── 28_naive_cow.png
    ├── 28_result_cow.jpg
    ├── 29_final_res.png
    ├── 29_final_res2.png
    ├── 29_inter_res.jpg
    ├── 2_final_res.png
    ├── 2_final_res2.png
    ├── 2_inter_res.jpg
    ├── 30_final_res.png
    ├── 30_final_res2.png
    ├── 30_inter_res.jpg
    ├── 31_final_res.png
    ├── 31_final_res2.png
    ├── 31_inter_res.jpg
    ├── 32_final_res.png
    ├── 32_final_res2.png
    ├── 32_inter_res.jpg
    ├── 33_final_res.png
    ├── 33_final_res2.png
    ├── 33_inter_res.jpg
    ├── 33_naive_buddha.png
    ├── 33_result_buddha.jpg
    ├── 34_final_res.png
    ├── 34_final_res2.png
    ├── 34_inter_res.jpg
    ├── 35_naive.jpg
    ├── 35_result.png
    ├── 3_final_res.png
    ├── 3_final_res2.png
    ├── 3_inter_res.jpg
    ├── 4_final_res.png
    ├── 4_final_res2.png
    ├── 4_inter_res.jpg
    ├── 5_final_res.png
    ├── 5_final_res2.png
    ├── 5_inter_res.jpg
    ├── 6_final_res.png
    ├── 6_final_res2.png
    ├── 6_inter_res.jpg
    ├── 7_final_res.png
    ├── 7_final_res2.png
    ├── 7_inter_res.jpg
    ├── 7_naive_popeye.png
    ├── 7_result_popeye.jpg
    ├── 7_target.jpg
    ├── 8_final_res.png
    ├── 8_final_res2.png
    ├── 8_inter_res.jpg
    ├── 8_naive_aircraft.png
    ├── 8_naive_balloon.jpg
    ├── 8_result_aircraft.png
    ├── 8_result_balloon.jpg
    ├── 9_final_res.png
    ├── 9_final_res2.png
    ├── 9_inter_res.jpg
    ├── 9_naive_dragon.png
    └── 9_result_dragon.jpg


/3rdparty/colorspace/colorcalc.c:
--------------------------------------------------------------------------------
  1 | /**
  2 |  * @file colorcalc.c
  3 |  * @author Pascal Getreuer 2010 <getreuer@gmail.com>
  4 |  *
  5 |  * This is a small command line program to demonstrate colorspace.c.  The
  6 |  * program accepts an sRGB color as input and transforms it to all the spaces
  7 |  * supported by colorspace.c.
  8 |  *
  9 |  * ==Usage==
 10 |  * The syntax for the program is
 11 |  *    colorcalc R G B
 12 |  * where R, G, B are values between 0 and 1 specifying a color in the gamma-
 13 |  * corrected sRGB color space.  For example,
 14 |  *    colorcalc 0.5 0.85 0.61
 15 |  *
 16 |  * ==Compiling Instructions==
 17 |  * Compile the files colorcalc.c and colorspace.c with an ANSI C compiler.  The
 18 |  * program is compiled with GCC by
 19 |  *    gcc colorcalc.c colorspace.c -lm -o colorcalc
 20 |  */
 21 | #include <stdio.h>
 22 | #include <stdlib.h>
 23 | #include "colorspace.h"
 24 | 
 25 | 
 26 | static void HelpMessage();
 27 | 
 28 | 
 29 | int main(int argc, char *argv[])
 30 | {
 31 | 	num R, G, B;
 32 | 	num D[3];
 33 | 	
 34 | 	
 35 | 	if(argc != 4)
 36 | 	{
 37 | 		HelpMessage();
 38 | 		return 1;
 39 | 	}
 40 | 	
 41 | 	/* Read the input sRGB values */
 42 | 	R = atof(argv[1]);
 43 | 	G = atof(argv[2]);
 44 | 	B = atof(argv[3]);
 45 | 	
 46 | 	if(!(0 <= R && R <= 1 && 0 <= G && G <= 1 && 0 <= B && B <= 1))
 47 | 		printf("\nWarning: Input sRGB values should be between 0 and 1.\n\n");
 48 | 	
 49 | 	printf("sRGB         R':%8.3f   G':%8.3f   B':%8.3f\n", R, G, B);
 50 | 	
 51 | 	/* Transform sRGB to Y'CbCr */
 52 | 	Rgb2Ycbcr(&D[0], &D[1], &D[2], R, G, B);
 53 | 	printf("Y'CbCr       Y':%8.3f   Cb:%8.3f   Cr:%8.3f\n", D[0], D[1], D[2]);
 54 | 	
 55 | 	/* Transform sRGB to JPEG-Y'CbCr */
 56 | 	Rgb2Jpegycbcr(&D[0], &D[1], &D[2], R, G, B);
 57 | 	printf("JPEG-Y'CbCr  Y':%8.3f   Cb:%8.3f   Cr:%8.3f\n", D[0], D[1], D[2]);
 58 | 	
 59 | 	/* Transform sRGB to Y'PbPr */
 60 | 	Rgb2Ypbpr(&D[0], &D[1], &D[2], R, G, B);
 61 | 	printf("Y'PbPr       Y':%8.3f   Pb:%8.3f   Pr:%8.3f\n", D[0], D[1], D[2]);
 62 | 	
 63 | 	/* Transform sRGB to Y'DbDr */
 64 | 	Rgb2Ydbdr(&D[0], &D[1], &D[2], R, G, B);
 65 | 	printf("Y'DbDr       Y':%8.3f   Db:%8.3f   Dr:%8.3f\n", D[0], D[1], D[2]);
 66 | 	
 67 | 	/* Transform sRGB to Y'UV */
 68 | 	Rgb2Yuv(&D[0], &D[1], &D[2], R, G, B);
 69 | 	printf("Y'UV         Y':%8.3f    U:%8.3f    V:%8.3f\n", D[0], D[1], D[2]);
 70 | 	
 71 | 	/* Transform sRGB to Y'IQ */
 72 | 	Rgb2Yiq(&D[0], &D[1], &D[2], R, G, B);
 73 | 	printf("Y'IQ         Y':%8.3f    I:%8.3f    Q:%8.3f\n", D[0], D[1], D[2]);
 74 | 	
 75 | 	/* Transform sRGB to HSV */
 76 | 	Rgb2Hsv(&D[0], &D[1], &D[2], R, G, B);
 77 | 	printf("HSV           H:%8.3f    S:%8.3f    V:%8.3f\n", D[0], D[1], D[2]);
 78 | 	
 79 | 	/* Transform sRGB to HSL */
 80 | 	Rgb2Hsl(&D[0], &D[1], &D[2], R, G, B);
 81 | 	printf("HSL           H:%8.3f    S:%8.3f    L:%8.3f\n", D[0], D[1], D[2]);
 82 | 	
 83 | 	/* Transform sRGB to HSI */
 84 | 	Rgb2Hsi(&D[0], &D[1], &D[2], R, G, B);
 85 | 	printf("HSI           H:%8.3f    S:%8.3f    I:%8.3f\n", D[0], D[1], D[2]);
 86 | 	
 87 | 	/* Transform sRGB to CIE XYZ */
 88 | 	Rgb2Xyz(&D[0], &D[1], &D[2], R, G, B);
 89 | 	printf("XYZ           X:%8.3f    Y:%8.3f    Z:%8.3f\n", D[0], D[1], D[2]);
 90 | 
 91 | 	/* Transform sRGB to CIE L*a*b */
 92 | 	Rgb2Lab(&D[0], &D[1], &D[2], R, G, B);
 93 | 	printf("L*a*b*       L*:%8.3f   a*:%8.3f   b*:%8.3f\n", D[0], D[1], D[2]);
 94 | 	
 95 | 	/* Transform sRGB to CIE L*u*v* */
 96 | 	Rgb2Luv(&D[0], &D[1], &D[2], R, G, B);
 97 | 	printf("L*u*v*       L*:%8.3f   u*:%8.3f   v*:%8.3f\n", D[0], D[1], D[2]);
 98 | 	
 99 | 	/* Transform sRGB to CIE L*C*H* */
100 | 	Rgb2Lch(&D[0], &D[1], &D[2], R, G, B);
101 | 	printf("L*C*H*       L*:%8.3f   C*:%8.3f   H*:%8.3f\n", D[0], D[1], D[2]);
102 | 	
103 | 	/* Transform sRGB to CIE CAT02 LMS */
104 | 	Rgb2Cat02lms(&D[0], &D[1], &D[2], R, G, B);
105 | 	printf("CAT02 LMS     L:%8.3f    M:%8.3f    S:%8.3f\n", D[0], D[1], D[2]);
106 | 	
107 | 	return 0;
108 | }
109 | 
110 | 
111 | /** @brief Print program help message */
112 | static void HelpMessage()
113 | {
114 | 	printf("Color calculator, P. Getreuer 2010\n");
115 | 	printf("\nSyntax: colorcalc R G B\n\n");
116 | 	printf("where R, G, B are values between 0 and 1 specifying a color in\n");
117 | 	printf("the gamma-corrected sRGB color space.  The color is transformed\n");
118 | 	printf("to all spaces supported by colorspace.c.\n\n");
119 | 	printf("Example: colorcalc 0.5 0.85 0.61\n");
120 | }
121 | 


--------------------------------------------------------------------------------
/3rdparty/colorspace/colorspace.h:
--------------------------------------------------------------------------------
 1 | /** 
 2 |  * @file colorspace.h 
 3 |  * @author Pascal Getreuer 2005-2010 <getreuer@gmail.com>
 4 |  */
 5 | #ifndef _COLORSPACE_H_
 6 | #define _COLORSPACE_H_
 7 | 
 8 | /** @brief Datatype to use for representing real numbers 
 9 |  * Set this typedef to either double or float depending on the application.
10 |  */
11 | typedef double num;
12 | 
13 | 
14 | /** @brief XYZ color of the D65 white point */
15 | #define WHITEPOINT_X	0.950456
16 | #define WHITEPOINT_Y	1.0
17 | #define WHITEPOINT_Z	1.088754
18 | 
19 | 
20 | 
21 | /** @brief struct for representing a color transform */
22 | typedef struct
23 | {
24 | 	int NumStages;
25 | 	void (*Fun[2])(num*, num*, num*, num, num, num);
26 | } colortransform;
27 | 
28 | int GetColorTransform(colortransform *Trans, const char *TransformString);
29 | void ApplyColorTransform(colortransform Trans, 
30 | 	num *D0, num *D1, num *D2, num S0, num S1, num S2);
31 | 
32 | void Rgb2Yuv(num *Y, num *U, num *V, num R, num G, num B);
33 | void Yuv2Rgb(num *R, num *G, num *B, num Y, num U, num V);
34 | void Rgb2Ycbcr(num *Y, num *Cb, num *Cr, num R, num G, num B);
35 | void Ycbcr2Rgb(num *R, num *G, num *B, num Y, num Cb, num Cr);
36 | void Rgb2Jpegycbcr(num *R, num *G, num *B, num Y, num Cb, num Cr);
37 | void Jpegycbcr2Rgb(num *R, num *G, num *B, num Y, num Cb, num Cr);
38 | void Rgb2Ypbpr(num *Y, num *Pb, num *Pr, num R, num G, num B);
39 | void Ypbpr2Rgb(num *R, num *G, num *B, num Y, num Pb, num Pr);
40 | void Rgb2Ydbdr(num *Y, num *Db, num *Dr, num R, num G, num B);
41 | void Ydbdr2Rgb(num *R, num *G, num *B, num Y, num Db, num Dr);
42 | void Rgb2Yiq(num *Y, num *I, num *Q, num R, num G, num B);
43 | void Yiq2Rgb(num *R, num *G, num *B, num Y, num I, num Q);
44 | 
45 | void Rgb2Hsv(num *H, num *S, num *V, num R, num G, num B);
46 | void Hsv2Rgb(num *R, num *G, num *B, num H, num S, num V);
47 | void Rgb2Hsl(num *H, num *S, num *L, num R, num G, num B);
48 | void Hsl2Rgb(num *R, num *G, num *B, num H, num S, num L);
49 | void Rgb2Hsi(num *H, num *S, num *I, num R, num G, num B);
50 | void Hsi2Rgb(num *R, num *G, num *B, num H, num S, num I);
51 | 
52 | void Rgb2Xyz(num *X, num *Y, num *Z, num R, num G, num B);
53 | void Xyz2Rgb(num *R, num *G, num *B, num X, num Y, num Z);
54 | void Xyz2Lab(num *L, num *a, num *b, num X, num Y, num Z);
55 | void Lab2Xyz(num *X, num *Y, num *Z, num L, num a, num b);
56 | void Xyz2Luv(num *L, num *u, num *v, num X, num Y, num Z);
57 | void Luv2Xyz(num *X, num *Y, num *Z, num L, num u, num v);
58 | void Xyz2Lch(num *L, num *C, num *H, num X, num Y, num Z);
59 | void Lch2Xyz(num *X, num *Y, num *Z, num L, num C, num H);
60 | void Xyz2Cat02lms(num *L, num *M, num *S, num X, num Y, num Z);
61 | void Cat02lms2Xyz(num *X, num *Y, num *Z, num L, num M, num S);
62 | 
63 | void Rgb2Lab(num *L, num *a, num *b, num R, num G, num B);
64 | void Lab2Rgb(num *R, num *G, num *B, num L, num a, num b);
65 | void Rgb2Luv(num *L, num *u, num *v, num R, num G, num B);
66 | void Luv2Rgb(num *R, num *G, num *B, num L, num u, num v);
67 | void Rgb2Lch(num *L, num *C, num *H, num R, num G, num B);
68 | void Lch2Rgb(num *R, num *G, num *B, num L, num C, num H);
69 | void Rgb2Cat02lms(num *L, num *M, num *S, num R, num G, num B);
70 | void Cat02lms2Rgb(num *R, num *G, num *B, num L, num M, num S);
71 | 
72 | #endif  /* _COLORSPACE_H_ */
73 | 


--------------------------------------------------------------------------------
/3rdparty/colorspace/colorspace_01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/colorspace/colorspace_01.jpg


--------------------------------------------------------------------------------
/3rdparty/colorspace/colorspace_02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/colorspace/colorspace_02.jpg


--------------------------------------------------------------------------------
/3rdparty/colorspace/colorspace_03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/colorspace/colorspace_03.jpg


--------------------------------------------------------------------------------
/3rdparty/colorspace/colorspace_ciedemo.m:
--------------------------------------------------------------------------------
 1 | % Demo for colorspace.m - the CIE xyY "tongue"
 2 | 
 3 | % Pascal Getreuer 2006
 4 | 
 5 | N = 800;
 6 | Nx = round(N*0.736);
 7 | Ny = round(N*0.84);
 8 | % Generate colors in the xyY color space
 9 | x = linspace(0,0.736,Nx);
10 | y = linspace(0,0.84,Ny);
11 | [xx,yy] = meshgrid(x,y);
12 | % i = (xx + yy <= 1.01 & (xx - 0.2)/2 - yy <= 0.02);
13 | 
14 | % Convert from xyY to XYZ
15 | a = 0.6491;
16 | X = a*xx;
17 | Y = a*yy;
18 | Z = a*(1 - xx - yy);
19 | 
20 | Corner = colorspace('xyz<-rgb', [1,0,0;0,1,0;0,0,1]);
21 | Corner = Corner(:,1:2)./repmat(sum(Corner,2),1,2);
22 | 
23 | v0x = Corner(3,1) - Corner(1,1);
24 | v0y = Corner(3,2) - Corner(1,2);
25 | v1x = Corner(2,1) - Corner(1,1);
26 | v1y = Corner(2,2) - Corner(1,2);
27 | v2x = xx - Corner(1,1);
28 | v2y = yy - Corner(1,2);
29 | 
30 | dot00 = v0x*v0x + v0y*v0y;
31 | dot01 = v0x*v1x + v0y*v1y;
32 | dot02 = v0x*v2x + v0y*v2y;
33 | dot11 = v1x*v1x + v1y*v1y;
34 | dot12 = v1x*v2x + v1y*v2y;
35 | Denom = dot00*dot11 - dot01*dot01;
36 | bu = (dot11*dot02 - dot01*dot12) / Denom;
37 | bv = (dot00*dot12 - dot01*dot02) / Denom;
38 | 
39 | 
40 | i = (bu > 0 & bv > 0 & bu + bv < 1);
41 | ie = conv2(double(i),[0,1,0;1,1,1;0,1,0],'same');
42 | 
43 | a = 0.3 + ie*0.7/5;
44 | X = a.*X;
45 | Y = a.*Y;
46 | Z = a.*Z;
47 | 
48 | % Convert from XYZ to R'G'B'
49 | Color = colorspace('rgb<-xyz',cat(3,X,Y,Z));
50 | Color = min(max(Color,0),1);
51 | 
52 | % Render the colors on the tongue
53 | clf;
54 | plot(xx,yy,'b.');
55 | image(x,y,Color)
56 | colormap(gray);
57 | set(gca,'YDir','normal');
58 | axis image
59 | 
60 | % The boundary of the tongue
61 | xy = [[0.1740, 0.0050];[0.1736, 0.0049];[0.1703, 0.0058];
62 |    [0.1566, 0.0177];[0.1440, 0.0297];[0.1241, 0.0578];
63 |    [0.1096, 0.0868];[0.0913, 0.1327];[0.0687, 0.2007];
64 |    [0.0454, 0.2950];[0.0235, 0.4127];[0.0082, 0.5384];
65 |    [0.0039, 0.6548];[0.0139, 0.7502];[0.0389, 0.8120];
66 |    [0.0743, 0.8338];[0.1142, 0.8262];[0.1547, 0.8059];
67 |    [0.1929, 0.7816];[0.2296, 0.7543];[0.2658, 0.7243];
68 |    [0.3016, 0.6923];[0.3373, 0.6589];[0.3731, 0.6245];
69 |    [0.4087, 0.5896];[0.4441, 0.5547];[0.4788, 0.5202];
70 |    [0.5125, 0.4866];[0.5448, 0.4544];[0.5752, 0.4242];
71 |    [0.6029, 0.3965];[0.6270, 0.3725];[0.6482, 0.3514];
72 |    [0.6658, 0.3340];[0.6801, 0.3197];[0.7006, 0.2993];
73 |    [0.7140, 0.2859];[0.7260, 0.2740];[0.7340, 0.2660]];
74 | % Make a smooth boundary with spline interpolation
75 | xi = [interp1(xy(:,1),1:0.25:size(xy,1),'spline'),xy(1,1)];
76 | yi = [interp1(xy(:,2),1:0.25:size(xy,1),'spline'),xy(1,2)];
77 | 
78 | % Draw the boundary of the tongue
79 | hold on;
80 | % set(patch([0.8;Corner([1,2,3,1],1);0.8;0.8;0;0;0.8],...
81 | %     [0.9;Corner([1,2,3,1],2);0.9;0;0;0.9;0.9],...
82 | %    [0,0,0] + 0.3),'EdgeColor','none');
83 | set(patch([0.8,-1e2,-1e2,0.8,xi(:).',0.8],[0.9,0.9,-1e2,-1e2,yi(:).',-1e2],...
84 |    [0,0,0]),'EdgeColor','none');
85 | plot(xi,yi,'w-');
86 | 
87 | for k = 0:8
88 |     set(text(xy(4 + k*4,1), xy(4 + k*4,2), sprintf('%d', 460 + k*20)),'Color',[1,1,1]);
89 | end
90 | 
91 | axis([0,0.8,0,0.9]);
92 | xlabel('x');
93 | ylabel('y');
94 | title('The CIE "tongue": the region of all colors over x and y');
95 | set(gca,'Color',[0,0,0]);
96 | shg;
97 | 


--------------------------------------------------------------------------------
/3rdparty/colorspace/colorspace_demo.m:
--------------------------------------------------------------------------------
  1 | function colorspace_demo(Cmd)
  2 | % Demo for colorspace.m - 3D visualizations of various color spaces
  3 | 
  4 | % Pascal Getreuer 2006
  5 | 
  6 | if nargin == 0
  7 |    % Create a figure with a drop-down menu
  8 |    figure('Color',[1,1,1]);
  9 |    h = uicontrol('Style','popup','Position',[15,10,90,21],...
 10 |       'BackgroundColor',[1,1,1],'Value',2,...
 11 |       'string',{'sRGB','Y''PbPr','HSV','HSL','L*a*b*','L*u*v*','L*ch'});
 12 |    set(h,'Callback',sprintf('%s(get(%.20g,''Value''))',mfilename,h));   
 13 |    Cmd = 2;
 14 | end
 15 | 
 16 | % Plot a figure
 17 | switch Cmd
 18 | case 1
 19 |    [x,y,z,Tri] = makeshape('Cube');
 20 |    CData = [x,y,z];
 21 |    myplot((x-0.5)*0.8,(y-0.5)*0.8,(z)*0.8,Tri,CData);
 22 |    coloraxis('R''',5,0.5*0.8);
 23 |    coloraxis('G''',6,0.5*0.8); 
 24 |    coloraxis('B''',3);    
 25 | case 2
 26 |    [x,y,z,Tri] = makeshape('Cylinder');
 27 |    CData = colorspace('rgb<-ypbpr',[z,x/2,y/2]);
 28 |    myplot(x,y,0.8*z,Tri,CData);
 29 |    coloraxis('Y''',3);
 30 |    coloraxis('P_b',5,0.8); 
 31 |    coloraxis('P_r',6,0.8); 
 32 | case 3
 33 |    [x,y,z,Tri] = makeshape('Hexacone');
 34 |    CData = colorspace('rgb<-hsv',[(pi+atan2(-y,-x))*180/pi,sqrt(x.^2+y.^2),z]);
 35 |    myplot(x,y,z,Tri,CData);
 36 |    coloraxis('H',1);
 37 |    coloraxis('S',2);
 38 |    coloraxis('V',3);
 39 | case 4
 40 |    [x,y,z,Tri] = makeshape('Double Hexacone');
 41 |    CData = colorspace('rgb<-hsl',[(pi+atan2(-y,-x))*180/pi,sqrt(x.^2+y.^2),z]);      
 42 |    myplot(x,y,2*z,Tri,CData);
 43 |    coloraxis('H',1);
 44 |    coloraxis('S',2);   
 45 |    coloraxis('L',4);
 46 | case 5
 47 |    [x,y,z,Tri] = makeshape('Blobs');
 48 |    CData = colorspace('rgb<-lab',[z*100,x*100,y*100]);
 49 |    myplot(x,y,2*z,Tri,CData);
 50 |    coloraxis('L*',4);
 51 |    coloraxis('a*',5,2); 
 52 |    coloraxis('b*',6,2); 
 53 | case 6
 54 |    [x,y,z,Tri] = makeshape('Blobs');
 55 |    CData = colorspace('rgb<-luv',[z*100,x*125,y*125]);
 56 |    myplot(x,y,2*z,Tri,CData);
 57 |    coloraxis('L*',4);
 58 |    coloraxis('u*',5,2); 
 59 |    coloraxis('v*',6,2);
 60 | case 7
 61 |    [x,y,z,Tri] = makeshape('Blobs');
 62 |    CData = colorspace('rgb<-lab',[z*100,x*100,y*100]);
 63 |    myplot(x,y,2*z,Tri,CData);
 64 |    coloraxis('L*',4);
 65 |    coloraxis('c',2); 
 66 |    coloraxis('h',1);
 67 | end
 68 | 
 69 | axis equal;
 70 | axis off;
 71 | pbaspect([1,1,1]);
 72 | view(70,27);
 73 | rotate3d on;
 74 | 
 75 | return;
 76 | 
 77 | 
 78 | function myplot(x,y,z,Tri,CData)
 79 | % Plot a triangular mesh with color data
 80 | cla;
 81 | CData = min(max(CData,0),1);
 82 | patch('Faces',Tri,'Vertices',[x,y,z],'FaceVertexCData',CData,...
 83 |    'FaceColor','interp','EdgeColor','none');
 84 | hold on;
 85 | return;
 86 | 
 87 | 
 88 | function coloraxis(Name,Type,h)
 89 | % Draw color axes as 3D objects
 90 | FontSize = 14;
 91 | 
 92 | switch Type
 93 | case 1
 94 |    set(text(-0.25,-1.3,1.1,Name),'FontWeight','bold',...
 95 |       'FontSize',FontSize,'Color',[0,0,0]);
 96 |    t = linspace(0,pi*3/2,60);
 97 |    x = cos(t)*1.1;
 98 |    y = sin(t)*1.1;
 99 |    set(plot3(x,y,zeros(size(x)),'k-'),'LineWidth',2.5,'Color',[1,1,1]*0.8);
100 |    x = [x,-0.1,0,-0.1];
101 |    y = [y,-1.05,-1.1,-1.15];
102 |    set(plot3(x,y,ones(size(x)),'k-'),'LineWidth',2.5);   
103 | case 2
104 |    set(text(0,-0.6,0.15,Name),'FontWeight','bold','FontSize',FontSize,'Color',[0,0,0]);
105 |    set(plot3([-0.05,0,0.05,0,0],[-0.9,-1,-0.9,-1,0],[0,0,0,0,0],'k-'),'LineWidth',2.5);
106 | case 3
107 |    set(text(0,0.15,1.3,Name),'FontWeight','bold','FontSize',FontSize,'Color',[0,0,0]);
108 |    set(plot3([0,0,0,0,0],[-0.05,0,0.05,0,0],[1.6,1.7,1.6,1.7,0],'k-'),'LineWidth',2.5);
109 | case 4
110 |    set(text(0,0.15,2.4,Name),'FontWeight','bold','FontSize',FontSize,'Color',[0,0,0]);
111 |    set(plot3([0,0,0,0,0],[-0.05,0,0.05,0,0],[2.4,2.5,2.4,2.5,0],'k-'),'LineWidth',2.5);
112 | case 5
113 |    set(text(0.6,0,h+0.15,Name),'FontWeight','bold','FontSize',FontSize,'Color',[0,0,0]);
114 |    set(plot3([0.9,1,0.9,1,-1,-0.9,-1,-0.9],[-0.05,0,0.05,0,0,-0.05,0,0.05],...
115 |       zeros(1,8)+h,'k-'),'LineWidth',2.5);
116 | case 6
117 |    set(text(0,0.6,h+0.15,Name),'FontWeight','bold','FontSize',FontSize,'Color',[0,0,0]);
118 |    set(plot3([-0.05,0,0.05,0,0,-0.05,0,0.05],[0.9,1,0.9,1,-1,-0.9,-1,-0.9],...
119 |       zeros(1,8)+h,'k-'),'LineWidth',2.5);
120 | end
121 | return;
122 | 
123 | 
124 | function [x,y,z,Tri] = makeshape(Shape)
125 | % Make a 3D shape: Shape = 'Cube', 'Cylinder', 'Cone', 'Double Cone', 'Blobs'
126 | 
127 | % Cube
128 | N = 12;    % Vertices per edge
129 | % Cylinder, Cone, Double Cone
130 | Nth = 25;  % Vertices over angles, (Nth - 1) should be a multiple of 12 
131 | Nr = 4;    % Vertices over radius
132 | Nz = 8;    % Vertices over z-dimension
133 | 
134 | switch lower(Shape)
135 | case 'cube'
136 |    [u,v] = meshgrid(linspace(0,1,N),linspace(0,1,N));
137 |    u = u(:);
138 |    v = v(:);
139 |    x = [u;u;u;u;zeros(N^2,1);ones(N^2,1)];
140 |    y = [v;v;zeros(N^2,1);ones(N^2,1);v;v];
141 |    z = [zeros(N^2,1);ones(N^2,1);v;v;u;u];
142 |    Tri = trigrid(N,N);
143 |    Tri = [Tri;N^2+Tri;2*N^2+Tri;3*N^2+Tri;4*N^2+Tri;5*N^2+Tri];
144 | case 'cylinder'
145 |    Nth = ceil(Nth*0.75);
146 |    [u,v] = meshgrid(linspace(0,pi*3/2,Nth),linspace(0,1,Nz));
147 |    Tri = trigrid(Nth,Nz);
148 |    x = cos(u(:));
149 |    y = sin(u(:));
150 |    z = v(:);
151 |    [u,v] = meshgrid(linspace(0,pi*3/2,Nth),linspace(0,1,Nr));
152 |    Tri = [Tri;Nth*Nz+trigrid(Nth,Nr);Nth*Nz+Nth*Nr+trigrid(Nth,Nr)];
153 |    x = [x;v(:).*cos(u(:));v(:).*cos(u(:))];
154 |    y = [y;v(:).*sin(u(:));v(:).*sin(u(:))];
155 |    z = [z;zeros(Nth*Nr,1);ones(Nth*Nr,1)];
156 |    [u,v] = meshgrid(linspace(0,1,Nr),linspace(0,1,Nz));
157 |    Tri = [Tri;Nth*Nz+2*Nth*Nr+trigrid(Nr,Nz);Nth*Nz+2*Nth*Nr+Nr*Nz+trigrid(Nr,Nz)];
158 |    x = [x;u(:);zeros(Nr*Nz,1)];
159 |    y = [y;zeros(Nr*Nz,1);-u(:)];
160 |    z = [z;v(:);v(:)];
161 | case 'cone'
162 |    [u,v] = meshgrid(linspace(0,2*pi,Nth),linspace(0,1,Nz));
163 |    Tri = trigrid(Nth,Nz);
164 |    x = v(:).*cos(u(:));
165 |    y = v(:).*sin(u(:));
166 |    z = v(:);
167 |    [u,v] = meshgrid(linspace(0,2*pi,Nth),linspace(0,1,Nr));
168 |    Tri = [Tri;Nth*Nz+trigrid(Nth,Nr);];
169 |    x = [x;v(:).*cos(u(:));];
170 |    y = [y;v(:).*sin(u(:));];
171 |    z = [z;ones(Nth*Nr,1)];
172 | case 'double cone'
173 |    Nz = floor(Nz/2)*2+1;
174 |    [u,v] = meshgrid(linspace(0,2*pi,Nth),linspace(0,1,Nz));
175 |    Tri = trigrid(Nth,Nz);
176 |    r = 1 - abs(2*v(:) - 1);
177 |    x = r.*cos(u(:));
178 |    y = r.*sin(u(:));
179 |    z = v(:);
180 | case 'hexacone'
181 |    [u,v] = meshgrid(linspace(0,2*pi,Nth),linspace(0,1,Nz));
182 |    Tri = trigrid(Nth,Nz);
183 |    r = 0.92./max(max(abs(cos(u)),abs(cos(u - pi/3))),abs(cos(u + pi/3)));
184 |    x = v(:).*cos(u(:)).*r(:);
185 |    y = v(:).*sin(u(:)).*r(:);
186 |    z = v(:);
187 |    [u,v] = meshgrid(linspace(0,2*pi,Nth),linspace(0,1,Nr));
188 |    Tri = [Tri;Nth*Nz+trigrid(Nth,Nr);];
189 |    v = 0.92*v./max(max(abs(cos(u)),abs(cos(u - pi/3))),abs(cos(u + pi/3)));
190 |    x = [x;v(:).*cos(u(:));];
191 |    y = [y;v(:).*sin(u(:));];
192 |    z = [z;ones(Nth*Nr,1)];
193 | case 'double hexacone'
194 |    Nz = floor(Nz/2)*2+1;
195 |    [u,v] = meshgrid(linspace(0,2*pi,Nth),linspace(0,1,Nz));
196 |    Tri = trigrid(Nth,Nz);
197 |    r = 1 - abs(2*v - 1);
198 |    r = 0.92*r./max(max(abs(cos(u)),abs(cos(u - pi/3))),abs(cos(u + pi/3)));
199 |    x = r(:).*cos(u(:));
200 |    y = r(:).*sin(u(:));
201 |    z = v(:);   
202 | case 'blobs'
203 |    Nz = 47;
204 |    [u,v] = meshgrid(linspace(0,2*pi,Nth),linspace(0,1,Nz));
205 |    Tri = trigrid(Nth,Nz);
206 |    r = sin(v(:)*pi*3).^2.*(1 - 0.6*abs(2*v(:) - 1));
207 |    x = r.*cos(u(:));
208 |    y = r.*sin(u(:));
209 |    z = v(:);   
210 | end
211 | return;
212 | 
213 | function Tri = trigrid(Nu,Nv)
214 | % Construct the connectivity data for a grid of triangular patches
215 | i = (1:(Nu-1)*Nv-1).';
216 | i(Nv:Nv:end) = [];
217 | Tri = [i,i+1,i+Nv;i+1,i+Nv+1,i+Nv];
218 | return;
219 | 
220 | 


--------------------------------------------------------------------------------
/3rdparty/colorspace/colorspace_test.m:
--------------------------------------------------------------------------------
 1 | % Transform accuracy test
 2 | % Test script for colorspace
 3 | 
 4 | % Pascal Getreuer 2006-2010
 5 | 
 6 | 
 7 | fprintf(['\nTransform accuracy test\n\n',...
 8 |       'To verify the invertibility of the color transfomations, this test\n',...
 9 |       'transforms sRGB data to a space, inverts, and compares with the\n',...
10 |       'original data.\n']);
11 | N = 1e5;            % Number of points to test
12 | A = rand(N,3);      % Generate points uniformly in the sRGB colorspace
13 | 
14 | % Include pure black and pure white
15 | A(1,:) = 0;
16 | A(2,:) = 1;
17 | 
18 | Space = {'YPbPr', 'YCbCr', 'JPEG-YCbCr', 'YDbDr', 'YIQ','YUV', 'HSV', ...
19 |       'HSL', 'HSI', 'XYZ', 'Lab', 'Luv', 'LCH', 'CAT02 LMS'};
20 | fprintf('\n Transform          RMSE Error   Max Error\n\n');
21 | 
22 | for k = 1:length(Space)
23 |    B = colorspace([Space{k},'<-RGB'],A);  % Convert to Space{k}
24 |    R = colorspace(['RGB<-',Space{k}],B);  % Convert back to sRGB
25 |    RMSE = sqrt(mean((A(:) - R(:)).^2));
26 |    MaxError = max(abs(A(:) - R(:)));
27 |    fprintf(' RGB<->%-10s   %9.2e    %9.2e\n', Space{k}, RMSE, MaxError);
28 | end
29 | 
30 | fprintf('\n\n');
31 | 


--------------------------------------------------------------------------------
/3rdparty/guided_filter/boxfilter.m:
--------------------------------------------------------------------------------
 1 | function imDst = boxfilter(imSrc, r)
 2 | 
 3 | %   BOXFILTER   O(1) time box filtering using cumulative sum
 4 | %
 5 | %   - Definition imDst(x, y)=sum(sum(imSrc(x-r:x+r,y-r:y+r)));
 6 | %   - Running time independent of r; 
 7 | %   - Equivalent to the function: colfilt(imSrc, [2*r+1, 2*r+1], 'sliding', @sum);
 8 | %   - But much faster.
 9 | 
10 | [hei, wid] = size(imSrc);
11 | imDst = zeros(size(imSrc));
12 | 
13 | %cumulative sum over Y axis
14 | imCum = cumsum(imSrc, 1);
15 | %difference over Y axis
16 | imDst(1:r+1, :) = imCum(1+r:2*r+1, :);
17 | imDst(r+2:hei-r, :) = imCum(2*r+2:hei, :) - imCum(1:hei-2*r-1, :);
18 | imDst(hei-r+1:hei, :) = repmat(imCum(hei, :), [r, 1]) - imCum(hei-2*r:hei-r-1, :);
19 | 
20 | %cumulative sum over X axis
21 | imCum = cumsum(imDst, 2);
22 | %difference over Y axis
23 | imDst(:, 1:r+1) = imCum(:, 1+r:2*r+1);
24 | imDst(:, r+2:wid-r) = imCum(:, 2*r+2:wid) - imCum(:, 1:wid-2*r-1);
25 | imDst(:, wid-r+1:wid) = repmat(imCum(:, wid), [1, r]) - imCum(:, wid-2*r:wid-r-1);
26 | end
27 | 
28 | 


--------------------------------------------------------------------------------
/3rdparty/guided_filter/example_enhancement.m:
--------------------------------------------------------------------------------
 1 | % example: detail enhancement
 2 | % figure 6 in our paper
 3 | 
 4 | close all;
 5 | 
 6 | I = double(imread('.\img_enhancement\tulips.bmp')) / 255;
 7 | p = I;
 8 | 
 9 | r = 16;
10 | eps = 0.1^2;
11 | 
12 | q = zeros(size(I));
13 | 
14 | q(:, :, 1) = guidedfilter(I(:, :, 1), p(:, :, 1), r, eps);
15 | q(:, :, 2) = guidedfilter(I(:, :, 2), p(:, :, 2), r, eps);
16 | q(:, :, 3) = guidedfilter(I(:, :, 3), p(:, :, 3), r, eps);
17 | 
18 | I_enhanced = (I - q) * 5 + q;
19 | 
20 | figure();
21 | imshow([I, q, I_enhanced], [0, 1]);
22 | 


--------------------------------------------------------------------------------
/3rdparty/guided_filter/example_feathering.m:
--------------------------------------------------------------------------------
 1 | % example: guided feathering
 2 | % figure 9 in our paper
 3 | 
 4 | close all;
 5 | 
 6 | I = double(imread('.\img_feathering\toy.bmp')) / 255;
 7 | p = double(rgb2gray(imread('.\img_feathering\toy-mask.bmp'))) / 255;
 8 | 
 9 | r = 60;
10 | eps = 10^-6;
11 | 
12 | q = guidedfilter_color(I, p, r, eps);
13 | 
14 | figure();
15 | imshow([I, repmat(p, [1, 1, 3]), repmat(q, [1, 1, 3])], [0, 1]);
16 | 


--------------------------------------------------------------------------------
/3rdparty/guided_filter/example_flash.m:
--------------------------------------------------------------------------------
 1 | % example: flash/noflash denoising
 2 | % figure 8 in our paper
 3 | % *** Errata ***: there is a typo in the caption of figure 8, the eps should be 0.02^2 instead of 0.2^2; sig_r should be 0.02 instead of 0.2.
 4 | 
 5 | close all;
 6 | 
 7 | I = double(imread('.\img_flash\cave-flash.bmp')) / 255;
 8 | p = double(imread('.\img_flash\cave-noflash.bmp')) / 255;
 9 | 
10 | r = 8;
11 | eps = 0.02^2;
12 | 
13 | q = zeros(size(I));
14 | 
15 | q(:, :, 1) = guidedfilter(I(:, :, 1), p(:, :, 1), r, eps);
16 | q(:, :, 2) = guidedfilter(I(:, :, 2), p(:, :, 2), r, eps);
17 | q(:, :, 3) = guidedfilter(I(:, :, 3), p(:, :, 3), r, eps);
18 | 
19 | figure();
20 | imshow([I, p, q], [0, 1]);
21 | 


--------------------------------------------------------------------------------
/3rdparty/guided_filter/example_smoothing.m:
--------------------------------------------------------------------------------
 1 | % example: edge-preserving smoothing
 2 | % figure 1 in our paper
 3 | 
 4 | close all;
 5 | 
 6 | I = double(imread('.\img_smoothing\cat.bmp')) / 255;
 7 | p = I;
 8 | r = 4; % try r=2, 4, or 8
 9 | eps = 0.2^2; % try eps=0.1^2, 0.2^2, 0.4^2
10 | 
11 | q = guidedfilter(I, p, r, eps);
12 | 
13 | figure();
14 | imshow([I, q], [0, 1]);
15 | 


--------------------------------------------------------------------------------
/3rdparty/guided_filter/guidedfilter.m:
--------------------------------------------------------------------------------
 1 | function q = guidedfilter(I, p, r, eps)
 2 | %   GUIDEDFILTER   O(1) time implementation of guided filter.
 3 | %
 4 | %   - guidance image: I (should be a gray-scale/single channel image)
 5 | %   - filtering input image: p (should be a gray-scale/single channel image)
 6 | %   - local window radius: r
 7 | %   - regularization parameter: eps
 8 | 
 9 | [hei, wid] = size(I);
10 | N = boxfilter(ones(hei, wid), r); % the size of each local patch; N=(2r+1)^2 except for boundary pixels.
11 | 
12 | mean_I = boxfilter(I, r) ./ N;
13 | mean_p = boxfilter(p, r) ./ N;
14 | mean_Ip = boxfilter(I.*p, r) ./ N;
15 | cov_Ip = mean_Ip - mean_I .* mean_p; % this is the covariance of (I, p) in each local patch.
16 | 
17 | mean_II = boxfilter(I.*I, r) ./ N;
18 | var_I = mean_II - mean_I .* mean_I;
19 | 
20 | a = cov_Ip ./ (var_I + eps); % Eqn. (5) in the paper;
21 | b = mean_p - a .* mean_I; % Eqn. (6) in the paper;
22 | 
23 | mean_a = boxfilter(a, r) ./ N;
24 | mean_b = boxfilter(b, r) ./ N;
25 | 
26 | q = mean_a .* I + mean_b; % Eqn. (8) in the paper;
27 | end


--------------------------------------------------------------------------------
/3rdparty/guided_filter/guidedfilter_color.m:
--------------------------------------------------------------------------------
 1 | function q = guidedfilter_color(I, p, r, eps)
 2 | %   GUIDEDFILTER_COLOR   O(1) time implementation of guided filter using a color image as the guidance.
 3 | %
 4 | %   - guidance image: I (should be a color (RGB) image)
 5 | %   - filtering input image: p (should be a gray-scale/single channel image)
 6 | %   - local window radius: r
 7 | %   - regularization parameter: eps
 8 | 
 9 | [hei, wid] = size(p);
10 | N = boxfilter(ones(hei, wid), r); % the size of each local patch; N=(2r+1)^2 except for boundary pixels.
11 | 
12 | mean_I_r = boxfilter(I(:, :, 1), r) ./ N;
13 | mean_I_g = boxfilter(I(:, :, 2), r) ./ N;
14 | mean_I_b = boxfilter(I(:, :, 3), r) ./ N;
15 | 
16 | mean_p = boxfilter(p, r) ./ N;
17 | 
18 | mean_Ip_r = boxfilter(I(:, :, 1).*p, r) ./ N;
19 | mean_Ip_g = boxfilter(I(:, :, 2).*p, r) ./ N;
20 | mean_Ip_b = boxfilter(I(:, :, 3).*p, r) ./ N;
21 | 
22 | % covariance of (I, p) in each local patch.
23 | cov_Ip_r = mean_Ip_r - mean_I_r .* mean_p;
24 | cov_Ip_g = mean_Ip_g - mean_I_g .* mean_p;
25 | cov_Ip_b = mean_Ip_b - mean_I_b .* mean_p;
26 | 
27 | % variance of I in each local patch: the matrix Sigma in Eqn (14).
28 | % Note the variance in each local patch is a 3x3 symmetric matrix:
29 | %           rr, rg, rb
30 | %   Sigma = rg, gg, gb
31 | %           rb, gb, bb
32 | var_I_rr = boxfilter(I(:, :, 1).*I(:, :, 1), r) ./ N - mean_I_r .*  mean_I_r; 
33 | var_I_rg = boxfilter(I(:, :, 1).*I(:, :, 2), r) ./ N - mean_I_r .*  mean_I_g; 
34 | var_I_rb = boxfilter(I(:, :, 1).*I(:, :, 3), r) ./ N - mean_I_r .*  mean_I_b; 
35 | var_I_gg = boxfilter(I(:, :, 2).*I(:, :, 2), r) ./ N - mean_I_g .*  mean_I_g; 
36 | var_I_gb = boxfilter(I(:, :, 2).*I(:, :, 3), r) ./ N - mean_I_g .*  mean_I_b; 
37 | var_I_bb = boxfilter(I(:, :, 3).*I(:, :, 3), r) ./ N - mean_I_b .*  mean_I_b; 
38 | 
39 | a = zeros(hei, wid, 3);
40 | for y=1:hei
41 |     for x=1:wid        
42 |         Sigma = [var_I_rr(y, x), var_I_rg(y, x), var_I_rb(y, x);
43 |             var_I_rg(y, x), var_I_gg(y, x), var_I_gb(y, x);
44 |             var_I_rb(y, x), var_I_gb(y, x), var_I_bb(y, x)];
45 |         %Sigma = Sigma + eps * eye(3);
46 |         
47 |         cov_Ip = [cov_Ip_r(y, x), cov_Ip_g(y, x), cov_Ip_b(y, x)];        
48 |         
49 |         a(y, x, :) = cov_Ip * inv(Sigma + eps * eye(3)); % Eqn. (14) in the paper;
50 |     end
51 | end
52 | 
53 | b = mean_p - a(:, :, 1) .* mean_I_r - a(:, :, 2) .* mean_I_g - a(:, :, 3) .* mean_I_b; % Eqn. (15) in the paper;
54 | 
55 | q = (boxfilter(a(:, :, 1), r).* I(:, :, 1)...
56 | + boxfilter(a(:, :, 2), r).* I(:, :, 2)...
57 | + boxfilter(a(:, :, 3), r).* I(:, :, 3)...
58 | + boxfilter(b, r)) ./ N;  % Eqn. (16) in the paper;
59 | end


--------------------------------------------------------------------------------
/3rdparty/guided_filter/img_enhancement/tulips.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/guided_filter/img_enhancement/tulips.bmp


--------------------------------------------------------------------------------
/3rdparty/guided_filter/img_feathering/toy-mask.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/guided_filter/img_feathering/toy-mask.bmp


--------------------------------------------------------------------------------
/3rdparty/guided_filter/img_feathering/toy.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/guided_filter/img_feathering/toy.bmp


--------------------------------------------------------------------------------
/3rdparty/guided_filter/img_flash/cave-flash.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/guided_filter/img_flash/cave-flash.bmp


--------------------------------------------------------------------------------
/3rdparty/guided_filter/img_flash/cave-noflash.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/guided_filter/img_flash/cave-noflash.bmp


--------------------------------------------------------------------------------
/3rdparty/guided_filter/img_smoothing/cat.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/guided_filter/img_smoothing/cat.bmp


--------------------------------------------------------------------------------
/3rdparty/guided_filter/readme.txt:
--------------------------------------------------------------------------------
 1 | 
 2 | ***************************************************************************************
 3 | ***************************************************************************************
 4 | 
 5 | Matlab demo code for "Guided Image Filtering" (ECCV 2010)
 6 | 
 7 | by Kaiming He (kahe@microsoft.com)
 8 | 
 9 | If you use/adapt our code in your work (either as a stand-alone tool or as a component 
10 | of any algorithm), you need to appropriately cite our ECCV 2010 paper.
11 | 
12 | This code is for academic purpose only. Not for commercial/industrial activities.
13 | 
14 | 
15 | The running time reported in the paper is from C++ implementation. This matlab code is
16 | a reference for those who would like to reimplement our method.
17 | 
18 | ***************************************************************************************
19 | ***************************************************************************************
20 | 
21 | Usage:
22 | 
23 | guidedfilter.m - guided filter implementation (Eqn(5), (6), (8) in the paper)
24 | guidedfilter_color.m - guided filter for color guidance (Eqn(14), (15), (16) in the paper)
25 | 
26 | Run the four examples to see the results shown in the paper.
27 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/allegro_emu.cpp:
--------------------------------------------------------------------------------
 1 | 
 2 | #include "allegro_emu.h"
 3 | #include <stdlib.h>
 4 | #include <stdio.h>
 5 | 
 6 | BITMAP *create_bitmap(int w, int h) {
 7 |   BITMAP *ans = new BITMAP(w, h);
 8 |   ans->data = new unsigned char[4*w*h]; // always 32bit
 9 |   ans->line = new unsigned char*[h];
10 |   for (int y = 0; y < h; y++) 
11 |     ans->line[y] = &ans->data[y*4*w];
12 |   return ans;
13 | }
14 | 
15 | void blit(BITMAP *a, BITMAP *b, int ax, int ay, int bx, int by, int w, int h) {
16 |   if (ax != 0 || ay != 0 || bx != 0 || by != 0) { fprintf(stderr, "blit not fully implemented, nonzero coords not supported\n"); exit(1); }
17 |   for (int y = 0; y < h; y++) {
18 |     int *arow = (int *) a->line[y];
19 |     int *brow = (int *) b->line[y];
20 |     for (int x = 0; x < w; x++) {
21 |       brow[x] = arow[x];
22 |     }
23 |   }
24 | }
25 | 
26 | void destroy_bitmap(BITMAP *bmp) {
27 | 	if (bmp) {
28 | 		delete[] bmp->line;
29 | 		delete[] bmp->data;
30 | 		delete bmp;
31 | 	}
32 | }
33 | 
34 | fixed fixmul(fixed a0, fixed b0) {
35 |   long long a = a0;
36 |   long long b = b0;
37 |   return (int) ((a*b)>>16);
38 | }
39 | 
40 | void clear(BITMAP *bmp) {
41 |   clear_to_color(bmp, 0);
42 | }
43 | 
44 | void clear_to_color(BITMAP *bmp, int c) {
45 |   for (int y = 0; y < bmp->h; y++) {
46 |     int *row = (int *) bmp->line[y];
47 |     for (int x = 0; x < bmp->w; x++) {
48 |       row[x] = c;
49 |     }
50 |   }
51 | }
52 | 
53 | int bitmap_color_depth(BITMAP *bmp) {
54 |   return 32;
55 | }
56 | 
57 | BITMAP *create_bitmap_ex(int depth, int w, int h) {
58 |   if (depth != 32) { fprintf(stderr, "depth not supported for create_bitmap_ex: %d\n", depth); exit(1); }
59 |   return create_bitmap(w, h);
60 | }
61 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/allegro_emu.h:
--------------------------------------------------------------------------------
 1 | 
 2 | #ifndef _allegro_emu_h
 3 | #define _allegro_emu_h
 4 | 
 5 | struct BITMAP {
 6 |   int w, h;
 7 |   unsigned char **line;
 8 |   unsigned char *data;
 9 |   BITMAP(int ww = 1, int hh = 1): w(ww), h(hh) {}
10 | };
11 | 
12 | inline int _getpixel32(BITMAP *a, int x, int y) { return ((int *) a->line[y])[x]; }
13 | inline void _putpixel32(BITMAP *a, int x, int y, int c) { ((int *) a->line[y])[x] = c; }
14 | 
15 | inline int getr32(int c) { return c&255; }
16 | inline int getg32(int c) { return (c>>8)&255; }
17 | inline int getb32(int c) { return (c>>16)&255; }
18 | 
19 | BITMAP *create_bitmap(int w, int h);
20 | void blit(BITMAP *a, BITMAP *b, int ax, int ay, int bx, int by, int w, int h);
21 | void destroy_bitmap(BITMAP *bmp);
22 | typedef int fixed;
23 | fixed fixmul(fixed a, fixed b);
24 | void clear(BITMAP *bmp);
25 | void clear_to_color(BITMAP *bmp, int c);
26 | 
27 | /*
28 | unsigned makecol(int r, int g, int b);
29 | int bitmap_mask_color(BITMAP *bmp);
30 | */
31 | 
32 | int bitmap_color_depth(BITMAP *bmp);
33 | BITMAP *create_bitmap_ex(int depth, int w, int h);
34 | 
35 | #endif
36 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/build_mac.sh:
--------------------------------------------------------------------------------
1 | mex CXX='/usr/local/bin/g++' CC='/usr/local/bin/gcc' LD='/usr/local/bin/g++' CXXOPTIMFLAGS='-O6 -w -s -ffast-math -fomit-frame-pointer -fstrength-reduce -fopenmp -msse2 -funroll-loops -fPIC' CXXFLAGS='-DNDEBUG -DUNIX_MODE -DMEXMODE -fopenmp' CXXLIBS='${CXXLIBS} -Wl,-e,mexFunction -shared' LDFLAGS='-Wl,-twolevel_namespace -arch i386 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -Wl,-exported_symbols_list,/Applications/MATLAB_R2009a.app/extern/lib/maci/mexFunction.map -fopenmp' mexutil.cpp nn.cpp nnmex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -cxx -output nnmex
2 | mex CXX='/usr/local/bin/g++' CC='/usr/local/bin/gcc' LD='/usr/local/bin/g++' CXXOPTIMFLAGS='-O6 -w -s -ffast-math -fomit-frame-pointer -fstrength-reduce -fopenmp -msse2 -funroll-loops -fPIC' CXXFLAGS='-DNDEBUG -DUNIX_MODE -DMEXMODE -fopenmp'  CXXLIBS='${CXXLIBS} -Wl,-e,mexFunction -shared' LDFLAGS='-Wl,-twolevel_namespace -arch i386 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -Wl,-exported_symbols_list,/Applications/MATLAB_R2009a.app/extern/lib/maci/mexFunction.map -fopenmp' mexutil.cpp nn.cpp votemex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -cxx -output votemex
3 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/build_unix.sh:
--------------------------------------------------------------------------------
1 | # Optimized (slow to build)
2 | mex CXXOPTIMFLAGS='-O6 -w -s -ffast-math -fomit-frame-pointer -fstrength-reduce -fopenmp -msse2 -funroll-loops -fPIC' CXXFLAGS='-DNDEBUG -DUNIX_MODE -DMEXMODE -fopenmp' CXXLIBS='${CXXLIBS} -Wl,--export-dynamic -Wl,-e,mexFunction -shared -lgomp' -inline knn.cpp mexutil.cpp nn.cpp nnmex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output nnmex -output nnmex
3 | mex CXXOPTIMFLAGS='-O6 -w -s -ffast-math -fomit-frame-pointer -fstrength-reduce -fopenmp -msse2 -funroll-loops -fPIC' CXXFLAGS='-DNDEBUG -DUNIX_MODE -DMEXMODE -fopenmp' CXXLIBS='${CXXLIBS} -Wl,--export-dynamic -Wl,-e,mexFunction -shared -lgomp' -inline knn.cpp mexutil.cpp nn.cpp votemex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output nnmex -output votemex
4 | 
5 | # Unoptimized (fast to build)
6 | #mex CXXOPTIMFLAGS='-w -fPIC' CXXFLAGS='-DNDEBUG -DUNIX_MODE -DMEXMODE -fopenmp' CXXLIBS='${CXXLIBS} -Wl,--export-dynamic -Wl,-e,mexFunction -shared -lgomp' -inline knn.cpp mexutil.cpp nn.cpp nnmex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output nnmex -output nnmex
7 | #mex CXXOPTIMFLAGS='-w -fPIC' CXXFLAGS='-DNDEBUG -DUNIX_MODE -DMEXMODE -fopenmp' CXXLIBS='${CXXLIBS} -Wl,--export-dynamic -Wl,-e,mexFunction -shared -lgomp' -inline knn.cpp mexutil.cpp nn.cpp votemex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output nnmex -output votemex
8 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/build_windows.bat:
--------------------------------------------------------------------------------
 1 | @rem It works without /nodefaultlib:libcmt.lib
 2 | 
 3 | @rem Optimized (slow to build)
 4 | @rem call mex OPTIMFLAGS="/Ox /Oi /Oy /DNDEBUG /fp:fast /arch:SSE2 /DMEX_MODE /openmp"  mexutil.cpp nn.cpp nnmex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output nnmex
 5 | @rem call mex OPTIMFLAGS="/Ox /Oi /Oy /DNDEBUG /fp:fast /arch:SSE2 /DMEX_MODE /openmp"  mexutil.cpp nn.cpp votemex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output votemex
 6 | 
 7 | @rem Unoptimized (fast to build)
 8 | call mex OPTIMFLAGS="/DNDEBUG /DMEX_MODE /openmp"  knn.cpp mexutil.cpp nn.cpp nnmex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output nnmex
 9 | call mex OPTIMFLAGS="/DNDEBUG /DMEX_MODE /openmp"  knn.cpp mexutil.cpp nn.cpp votemex.cpp patch.cpp vecnn.cpp simnn.cpp allegro_emu.cpp -output votemex
10 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/console_test_descriptor_mex.m:
--------------------------------------------------------------------------------
 1 | %------------------------------------------------------------------------%
 2 | % Copyright 2008-2009 Adobe Systems Inc., for noncommercial use only.
 3 | % Citation:
 4 | %   Connelly Barnes, Eli Shechtman, Adam Finkelstein, and Dan B Goldman.
 5 | %   PatchMatch: A Randomized Correspondence Algorithm for Structural Image
 6 | %   Editing. ACM Transactions on Graphics (Proc. SIGGRAPH), 28(3), 2009
 7 | %   http://www.cs.princeton.edu/gfx/pubs/Barnes_2009_PAR/
 8 | % Main contact: csbarnes@cs.princeton.edu  (Connelly)
 9 | % Version: 1.0, 21-June-2008
10 | %------------------------------------------------------------------------%
11 | 
12 | % Test 'image mode' nnmex, and votemex (see test_square.m and test_daisy.m for tests of 'descriptor mode' nnmex).
13 | 
14 | cores = 4;    % Use more cores for more speed
15 | 
16 | disp('start testing descriptor mode');
17 | 
18 | if cores==1
19 |   algo = 'cpu';
20 | else
21 |   algo = 'cputiled';
22 | end
23 | 
24 | 
25 | A=imread('b.png');
26 | B=imread('c.jpg');
27 | B=B(1:end-1,1:end-1,:);
28 | 
29 | SA = A; SA(:,:,4:6) = A; SA(:,:,7:9) = A; SA = double(SA);
30 | SB = B; SB(:,:,4:6) = B; SB(:,:,7:9) = B; SB = double(SB);
31 | disp('data generated');
32 | 
33 | patch_w = 7;
34 | 
35 | % Display field
36 | ann = nnmex(SA, SB, algo, [], [], [], [], [], [], cores);
37 | bnn = nnmex(SB, SA, algo, [], [], [], [], [], [], cores);
38 | 
39 | % Display reconstruction
40 | writeim(votemex(B, ann), 'test13.png')       % Coherence
41 | writeim(votemex(B, ann, bnn), 'test14.png')  % BDS
42 | 
43 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/console_test_knn.m:
--------------------------------------------------------------------------------
 1 | 
 2 | cores = 2;
 3 | 
 4 | % kNN without enrichment
 5 | b=imread('b.png');
 6 | c=imread('c.jpgg');
 7 | tic;
 8 | cnn=nnmex(b, b, 'cputiled', 7, 16, [], [], [], [], cores, [], [], [], [], [], 4);
 9 | toc
10 | writeim(cnn(:,:,1,1),'test17.png')
11 | writeim(cnn(:,:,1,2),'test18.png')
12 | writeim(cnn(:,:,1,3),'test19.png')
13 | writeim(cnn(:,:,1,4),'test20.png')
14 | D = sqrt(double(cnn(:,:,3,:)));
15 | format long;
16 | disp(['Average dist (no enrichment):', num2str(mean(D(:)))]);
17 | 
18 | % kNN with enrichment -- both images must be the same. Enrichment requires the number of NN iterations to be even -- if not it will round down to the next even number.
19 | tic;
20 | cnn=nnmex(b, b, 'enrich', 7, 6, [], [], [], [], cores, [], [], [], [], [], 4);
21 | toc
22 | writeim(cnn(:,:,1,1),'test21.png')
23 | writeim(cnn(:,:,1,2),'test22.png')
24 | writeim(cnn(:,:,1,3),'test23.png')
25 | writeim(cnn(:,:,1,4),'test24.png')
26 | D = sqrt(double(cnn(:,:,3,:)));
27 | disp(['Average dist (enrichment):', num2str(mean(D(:)))]);
28 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/console_test_mex.m:
--------------------------------------------------------------------------------
 1 | %------------------------------------------------------------------------%
 2 | % Copyright 2008-2009 Adobe Systems Inc., for noncommercial use only.
 3 | % Citation:
 4 | %   Connelly Barnes, Eli Shechtman, Adam Finkelstein, and Dan B Goldman.
 5 | %   PatchMatch: A Randomized Correspondence Algorithm for Structural Image
 6 | %   Editing. ACM Transactions on Graphics (Proc. SIGGRAPH), 28(3), 2009
 7 | %   http://www.cs.princeton.edu/gfx/pubs/Barnes_2009_PAR/
 8 | % Main contact: csbarnes@cs.princeton.edu  (Connelly)
 9 | % Version: 1.0, 21-June-2008
10 | %------------------------------------------------------------------------%
11 | 
12 | % Test 'image mode' nnmex, and votemex (see test_square.m and test_daisy.m for tests of 'descriptor mode' nnmex).
13 | 
14 | cores = 4;    % Use more cores for more speed
15 | 
16 | if cores==1
17 |   algo = 'cpu';
18 | else
19 |   algo = 'cputiled';
20 | end
21 | 
22 | A=imread('in.png');
23 | B=imread('tar.png');
24 | A = imhistmatch(A, B);
25 | figure; imshow(A)
26 | figure; imshow(B)
27 | B=B(1:end-1,1:end-1,:);
28 | 
29 | patch_w = 7;
30 | ann0 = nnmex(A, B, algo, [], [], [], [], [], [], cores);   % Warm up
31 | 
32 | % Benchmark
33 | tic;
34 | nnmex(A, B, algo, [], [], [], [], [], [], cores);
35 | nnmex(B, A, algo, [], [], [], [], [], [], cores);
36 | disp(['NN A <-> B time: ', num2str(toc), ' sec']);
37 | 
38 | % Display field
39 | ann = nnmex(A, B, algo, [], [], [], [], [], [], cores);
40 | bnn = nnmex(B, A, algo, [], [], [], [], [], [], cores);
41 | writeim(ann(:,:,1), 'test1.png');
42 | writeim(sqrt(double(ann(1:end-patch_w,1:end-patch_w,3))), 'test2.png');
43 | 
44 | % Display reconstruction
45 | writeim(votemex(B, ann), 'test3.png')       % Coherence
46 | writeim(votemex(B, ann, bnn), 'test4.png')  % BDS
47 | 
48 | % Test 3x3 patches, and clipping
49 | patch_w = 3;
50 | ann = nnmex(A, B, algo, patch_w, [], [], [], [], [], cores);
51 | bnn = nnmex(B, A, algo, patch_w, [], [], [], [], [], cores);
52 | % figure
53 | ann(1,1,1) = -2000;
54 | ann(2,1,1) = 2000;
55 | ann(3,1,2) = 2000;
56 | ann(4,1,2) = -2000;
57 | bnn(1,1,1) = -2000;
58 | bnn(2,1,1) = 2000;
59 | bnn(3,1,2) = 2000;
60 | bnn(4,1,2) = -2000;
61 | % imshow(votemex(B, ann, bnn, algo, patch_w));
62 | 
63 | % Test initial guess
64 | tic;
65 | annp = nnmex(A, B, algo, [], 0, [], [], [], [], cores, [], [], ann0);
66 | disp(['Initial guess mode run for 0 iterations: ', num2str(toc), ' sec']);
67 | writeim(votemex(B, annp), 'test5.png')       % Coherence
68 | 
69 | ann0(1:200,1:200) = 0;
70 | tic;
71 | annp = nnmex(A, B, algo, [], [], [], [], [], [], cores, [], [], ann0);
72 | disp(['Initial guess mode run for 5 iterations: ', num2str(toc), ' sec']);
73 | writeim(votemex(B, annp), 'test6.png')       % Coherence
74 | 
75 | 
76 | %close all;
77 | %% Test for memory leaks
78 | %A=imresize(A,0.25);
79 | %B=imresize(B,0.25);
80 | %B=B(1:end-1,1:end-1,:);
81 | %ann = nnmex(A, B); bnn = nnmex(B, A);
82 | %
83 | %user = memory;
84 | %disp(['before memory leak test: ', num2str(user.MemUsedMATLAB/1e6), ' MB']);
85 | %for i=1:100
86 | %  ann = nnmex(A, B); bnn = nnmex(B, A);
87 | %end
88 | %user = memory;
89 | %disp(['after memory leak test: ', num2str(user.MemUsedMATLAB/1e6), ' MB']);
90 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/console_test_rot_scale.m:
--------------------------------------------------------------------------------
 1 | 
 2 | b=imread('b.png');
 3 | c=imread('c.png');
 4 | tic; cnn=nnmex(c,b,'rotscale',7,20); toc
 5 | writeim(cnn(:,:,1),'test7.png')
 6 | writeim(cnn(:,:,4),'test8.png')
 7 | 
 8 | % Limiting to only unity scales on this input still works, as the object hasn't changed size too much
 9 | tic; cnn=nnmex(c,b,'rotscale',7,20, [], [], [], [], [], [], [], [], [], [], [], 1); toc
10 | writeim(cnn(:,:,1),'test9.png')
11 | writeim(cnn(:,:,4),'test10.png')
12 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/gen_all.m:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | N = 24;
 4 | patch = 7;
 5 | 
 6 | for i = 1 : N
 7 |     i
 8 |     exp_folder = ['D:\Dropbox\Public\StyleTransfer\GainMapResults\results_9_9\segs'];
 9 |     A = imread([exp_folder '\in' int2str(i) '.png']);
10 |     B = imread([exp_folder '\tar' int2str(i) '.png']);
11 |     
12 |     layers = {'relu1_1', 'relu2_1', 'relu3_1', 'relu4_1', 'relu5_1'};
13 |     num_features = [64, 128, 256, 512, 512];
14 |     
15 |     [A_f, B_f] = load_vgg_features([exp_folder '\segmentations_' int2str(i)], i, A, B, layers, num_features);
16 |     
17 |     [C, field] = neural_patchmatch(A, B, A_f, B_f, patch);
18 |     
19 |     imwrite(C, [exp_folder '\match' int2str(i) '.png']);
20 | end 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/knn.h:
--------------------------------------------------------------------------------
  1 | 
  2 | /* PatchMatch finding k-NN, with similarity transform of patches (rotation+scale). */
  3 | 
  4 | #ifndef _knn_h
  5 | #define _knn_h
  6 | 
  7 | #include "nn.h"
  8 | #include "simnn.h"
  9 | #include "vecnn.h"
 10 | 
 11 | #define SAVE_DIST           0
 12 | 
 13 | #define VBMP VECBITMAP<int>
 14 | 
 15 | BITMAP *greyscale(BITMAP *a);
 16 | BITMAP *greyscale16(BITMAP *a);
 17 | BITMAP *greyscale_to_color(BITMAP *a);
 18 | BITMAP *gaussian_blur16(BITMAP *a, double sigma);
 19 | BITMAP *greyscale16_to_color(BITMAP *a);
 20 | BITMAP *gaussian_deriv_angle(BITMAP *a, double sigma, BITMAP **dx_out=NULL, BITMAP **dy_out=NULL);
 21 | 
 22 | BITMAP *color_gaussian_blur(BITMAP *a, double sigma, int aconstraint_alpha);
 23 | 
 24 | BITMAP *extract_vbmp(VBMP *bmp, int i);
 25 | void insert_vbmp(VBMP *bmp, int i, BITMAP *a);
 26 | //void sort_knn(Params *p, BITMAP *a, VBMP *ann, VBMP *ann_sim, VBMP *annd);
 27 | VBMP *copy_vbmp(VBMP *a);
 28 | 
 29 | #define N_PRINCIPAL_ANGLE_SHIFT 8
 30 | #define N_PRINCIPAL_ANGLE (1<<N_PRINCIPAL_ANGLE_SHIFT)
 31 | 
 32 | class PRINCIPAL_ANGLE { public:
 33 |   BITMAP *angle[N_PRINCIPAL_ANGLE];
 34 | };
 35 | 
 36 | PRINCIPAL_ANGLE *create_principal_angle(Params *p, BITMAP *bmp);
 37 | void destroy_principal_angle(PRINCIPAL_ANGLE *b);
 38 | int get_principal_angle(Params *p, PRINCIPAL_ANGLE *b, int x0, int y0, int scale);
 39 | 
 40 | VBMP *knn_init_nn(Params *p, BITMAP *a, BITMAP *b, VBMP *&ann_sim, PRINCIPAL_ANGLE *pa=NULL);
 41 | VBMP *knn_init_dist(Params *p, BITMAP *a, BITMAP *b, VBMP *ann, VBMP *ann_sim);
 42 | 
 43 | void knn(Params *p, BITMAP *a, BITMAP *b,
 44 |          VBMP *&ann, VBMP *&ann_sim, VBMP *&annd,
 45 |          RegionMasks *amask=NULL, BITMAP *bmask=NULL,
 46 |          int level=0, int em_iter=0, RecomposeParams *rp=NULL, int offset_iter=0, int update_type=0, int cache_b=0,
 47 |          RegionMasks *region_masks=NULL, int tiles=-1, PRINCIPAL_ANGLE *pa=NULL, int save_first=0);
 48 | 
 49 | class KNNWeightFunc { public:
 50 |   virtual double weight(double d, int is_center) = 0;
 51 | };
 52 | 
 53 | class KNNSolverWeightFunc: public KNNWeightFunc { public:
 54 |   double param[3];
 55 |   KNNSolverWeightFunc(double x[3]);
 56 |   virtual double weight(double d, int is_center);
 57 | };
 58 | 
 59 | class ObjectiveFunc { public:
 60 |   virtual double f(double x[]) = 0;
 61 | };
 62 | 
 63 | double patsearch(ObjectiveFunc *f, double *x, double *ap, int n, int iters);
 64 | 
 65 | BITMAP *knn_vote(Params *p, BITMAP *b,
 66 |                  VBMP *ann, VBMP *ann_sim, VBMP *annd, VBMP *bnn=NULL, VBMP *bnn_sim=NULL,
 67 |                  BITMAP *bmask=NULL, BITMAP *bweight=NULL,
 68 |                  double coherence_weight=COHERENCE_WEIGHT, double complete_weight=COMPLETE_WEIGHT,
 69 |                  RegionMasks *amask=NULL, BITMAP *aweight=NULL, BITMAP *ainit=NULL, RegionMasks *region_masks=NULL, BITMAP *aconstraint=NULL, int mask_self_only=0, KNNWeightFunc *weight_func=NULL, double **accum_out=NULL);
 70 | 
 71 | BITMAP *knn_vote_solve(Params *p, BITMAP *b,
 72 |                  VBMP *ann, VBMP *ann_sim, VBMP *annd, int n, BITMAP *aorig, double weight_out[3]);
 73 | 
 74 | void knn_vis(Params *p, BITMAP *a, VBMP *ann, VBMP *ann_sim, VBMP *annd, int is_bitmap=0, BITMAP *vote=NULL, BITMAP *orig=NULL, BITMAP *vote_uniform=NULL);
 75 | 
 76 | void knn_dual_vis(Params *p, BITMAP *a, BITMAP *b, VBMP *ann, VBMP *ann_sim, VBMP *annd, int is_bitmap=0, BITMAP *vote=NULL, BITMAP *orig=NULL);
 77 | 
 78 | double knn_avg_dist(Params *p, VBMP *annd);
 79 | 
 80 | void knn_enrich(Params *p, BITMAP *a, BITMAP *b, VBMP *ann, VBMP *ann_sim, VBMP *annd, PRINCIPAL_ANGLE *pa=NULL);
 81 | 
 82 | void knn_enrich3(Params *p, BITMAP *a, BITMAP *b, VBMP *ann, VBMP *ann_sim, VBMP *annd, PRINCIPAL_ANGLE *pa=NULL);
 83 | 
 84 | void knn_enrich4(Params *p, BITMAP *a, BITMAP *b, VBMP *ann, VBMP *ann_sim, VBMP *annd, PRINCIPAL_ANGLE *pa=NULL);
 85 | 
 86 | void knn_inverse_enrich(Params *p, BITMAP *a, BITMAP *b, VBMP *ann, VBMP *ann_sim, VBMP *annd, PRINCIPAL_ANGLE *pa=NULL);
 87 | 
 88 | void knn_inverse_enrich2(Params *p, BITMAP *a, BITMAP *b, VBMP *ann, VBMP *ann_sim, VBMP *annd, PRINCIPAL_ANGLE *pa=NULL);
 89 | 
 90 | void knn_check(Params *p, BITMAP *a, BITMAP *b, VBMP *ann, VBMP *ann_sim, VBMP *annd, int check_duplicates=1);
 91 | 
 92 | void save_dist(Params *p, VBMP *annd, const char *suffix);
 93 | 
 94 | /* Also changes p->knn to kp. */
 95 | void change_knn(Params *p, BITMAP *a, BITMAP *b, VBMP *&ann, VBMP *&ann_sim, VBMP *&annd, int kp, PRINCIPAL_ANGLE *pa=NULL);
 96 | 
 97 | void combine_knn(Params *p1, Params *p2, BITMAP *a, BITMAP *b, VBMP *ann1, VBMP *ann_sim1, VBMP *annd1, VBMP *ann2, VBMP *ann_sim2, VBMP *annd2, VBMP *&ann, VBMP *&ann_sim, VBMP *&annd);
 98 | 
 99 | void check_change_knn(Params *p, BITMAP *a, BITMAP *b);
100 | 
101 | void sort_knn(Params *p, VBMP *ann, VBMP *ann_sim, VBMP *annd);
102 | 
103 | #endif
104 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/load_vgg_features.m:
--------------------------------------------------------------------------------
 1 | function [A_f, B_f] = load_vgg_features(exp_folder, id, A, B, layers, num_features)
 2 |     [hA, wA, cA] = size(A);
 3 |     [hB, wB, cB] = size(B);
 4 |     
 5 |     total_num_features = sum(num_features);
 6 |     A_f = zeros(hA, wA, total_num_features);
 7 |     B_f = zeros(hB, wB, total_num_features);
 8 |     
 9 |     index = 0;
10 |     
11 |     for i = 1 : length(layers)
12 |         layer = layers{i}
13 |         num_f = num_features(i)
14 |            
15 |         
16 |         for j = 1 : num_f
17 |             prefix = [exp_folder '\' layer '\content_' int2str(j)];
18 |             content_f = load_img(prefix);
19 |             prefix = [exp_folder '\' layer '\style_' int2str(j)];
20 |             style_f = load_img(prefix);
21 |             
22 |             content_f = imresize(content_f, [hA, wA]);
23 |             style_f   = imresize(style_f  , [hB, wB]);
24 |             
25 |             index = index + 1;
26 |             A_f(:,:,index) = content_f;
27 |             B_f(:,:,index) = style_f;
28 |         end 
29 |     end
30 |     
31 | end 
32 | 
33 | function img = load_img(prefix)
34 |     img = im2double(imread([prefix '.png']));
35 |     txt = load([prefix '.txt']);
36 |     img = img * (txt(2) - txt(1)) + txt(1);
37 | end 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/log.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/patchmatch-2.0/log.txt


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/mex.sln:
--------------------------------------------------------------------------------
 1 | 
 2 | Microsoft Visual Studio Solution File, Format Version 12.00
 3 | # Visual Studio 2013
 4 | VisualStudioVersion = 12.0.31101.0
 5 | MinimumVisualStudioVersion = 10.0.40219.1
 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nnmex", "nnmex\nnmex.vcproj", "{E6C3A339-5722-4328-81F5-B52D79CB2139}"
 7 | EndProject
 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "votemex", "votemex\votemex.vcproj", "{D08F59CD-D05E-4CA0-AA34-7EBB74044150}"
 9 | EndProject
10 | Global
11 | 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | 		Debug|Win32 = Debug|Win32
13 | 		Release|Win32 = Release|Win32
14 | 	EndGlobalSection
15 | 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | 		{E6C3A339-5722-4328-81F5-B52D79CB2139}.Debug|Win32.ActiveCfg = Debug|Win32
17 | 		{E6C3A339-5722-4328-81F5-B52D79CB2139}.Debug|Win32.Build.0 = Debug|Win32
18 | 		{E6C3A339-5722-4328-81F5-B52D79CB2139}.Release|Win32.ActiveCfg = Release|Win32
19 | 		{E6C3A339-5722-4328-81F5-B52D79CB2139}.Release|Win32.Build.0 = Release|Win32
20 | 		{D08F59CD-D05E-4CA0-AA34-7EBB74044150}.Debug|Win32.ActiveCfg = Debug|Win32
21 | 		{D08F59CD-D05E-4CA0-AA34-7EBB74044150}.Debug|Win32.Build.0 = Debug|Win32
22 | 		{D08F59CD-D05E-4CA0-AA34-7EBB74044150}.Release|Win32.ActiveCfg = Release|Win32
23 | 		{D08F59CD-D05E-4CA0-AA34-7EBB74044150}.Release|Win32.Build.0 = Release|Win32
24 | 	EndGlobalSection
25 | 	GlobalSection(SolutionProperties) = preSolution
26 | 		HideSolutionNode = FALSE
27 | 	EndGlobalSection
28 | EndGlobal
29 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/mex.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/patchmatch-2.0/mex.v12.suo


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/mexutil.cpp:
--------------------------------------------------------------------------------
  1 | 
  2 | #include "mexutil.h"
  3 | #include "nn.h"
  4 | #include <string.h>
  5 | 
  6 | // stack RGB to a single 32bit integer
  7 | BITMAP *convert_bitmap(const mxArray *A) {
  8 |   if (mxGetNumberOfDimensions(A) != 3) { mexErrMsgTxt("dims != 3"); }
  9 |   if (mxGetDimensions(A)[2] != 3) { mexErrMsgTxt("color channels != 3"); }
 10 | 
 11 | 	// matlab, h * w * n: (y, x, i) -> y + x * h + i * w * h
 12 |   int h = mxGetDimensions(A)[0];
 13 |   int w = mxGetDimensions(A)[1];
 14 | 	int offset = h * w;
 15 | 	int offset2 = offset << 1; // h * w * 2
 16 | 
 17 |   if (mxIsUint8(A)) {
 18 |     unsigned char *data = (unsigned char *) mxGetData(A);
 19 |     BITMAP *ans = create_bitmap(w, h);
 20 | 		for (int y = 0; y < h; y++) {
 21 |       int *row = (int *) ans->line[y];
 22 | 			for (int x = 0; x < w; x++) {
 23 | 				unsigned char *base = data + y + x * h;
 24 | 				int r = base[0];
 25 | 				int g = base[offset];
 26 | 				int b = base[offset2];
 27 | 				clip_value<int>(&r, 0, 255);
 28 | 				clip_value<int>(&g, 0, 255);
 29 | 				clip_value<int>(&b, 0, 255);
 30 |         row[x] = r|(g<<8)|(b<<16);
 31 |       }
 32 |     }
 33 |     return ans;
 34 |   } 
 35 | 	else if (mxIsSingle(A)) {
 36 |     float *data = (float *) mxGetData(A);
 37 |     BITMAP *ans = create_bitmap(w, h);
 38 |     for (int y = 0; y < h; y++) {
 39 |       int *row = (int *) ans->line[y];
 40 |       for (int x = 0; x < w; x++) {
 41 | 				float *base = data + y + x * h;
 42 |         float r = base[0];
 43 |         float g = base[offset];
 44 |         float b = base[offset2];
 45 | 				clip_value<float>(&r, 0, 1);
 46 | 				clip_value<float>(&g, 0, 1);
 47 | 				clip_value<float>(&b, 0, 1);
 48 |         row[x] = int(r*255)|(int(g*255)<<8)|(int(b*255)<<16);
 49 |       }
 50 |     }
 51 |     return ans;
 52 |   } 
 53 | 	else if (mxIsDouble(A)) {
 54 |     double *data = (double *) mxGetData(A);
 55 |     BITMAP *ans = create_bitmap(w, h);
 56 |     for (int y = 0; y < h; y++) {
 57 |       int *row = (int *) ans->line[y];
 58 |       for (int x = 0; x < w; x++) {
 59 | 				double *base = data + y + x * h;
 60 |         double r = base[0];
 61 |         double g = base[offset];
 62 |         double b = base[offset2];
 63 |         clip_value<double>(&r, 0, 1);
 64 | 				clip_value<double>(&g, 0, 1);
 65 | 				clip_value<double>(&b, 0, 1);
 66 | 				row[x] = int(r*255)|(int(g*255)<<8)|(int(b*255)<<16);
 67 |       }
 68 |     }
 69 |     return ans;
 70 |   } 
 71 | 	else {
 72 |     mexErrMsgTxt("bitmap not uint8, single, or double");
 73 | 		return NULL;
 74 |   }
 75 | }
 76 | 
 77 | BITMAP *convert_bitmapf(const mxArray *A) {
 78 |   if (!(mxGetNumberOfDimensions(A) == 2 ||
 79 |        (mxGetNumberOfDimensions(A) == 3 && mxGetDimensions(A)[2] == 3))) { mexErrMsgTxt("float bitmap doesn't have 2 dims or 3 dims with 3 channels"); }
 80 | 
 81 |   int h = mxGetDimensions(A)[0];
 82 |   int w = mxGetDimensions(A)[1];
 83 | 
 84 |   if (mxIsUint8(A)) { // treated as 32bit float
 85 |     unsigned char *data = (unsigned char *) mxGetData(A);
 86 |     BITMAP *ans = create_bitmap(w, h);
 87 |     for (int y = 0; y < h; y++) {
 88 |       float *row = (float *) ans->line[y];
 89 |       for (int x = 0; x < w; x++) {
 90 |         row[x] = data[y+x*h];
 91 |       }
 92 |     }
 93 |     return ans;
 94 |   } 
 95 | 	else if (mxIsDouble(A)) {
 96 |     double *data = (double *) mxGetData(A);
 97 |     BITMAP *ans = create_bitmap(w, h);
 98 |     for (int y = 0; y < h; y++) {
 99 |       float *row = (float *) ans->line[y];
100 |       for (int x = 0; x < w; x++) {
101 |         row[x] = data[y+x*h];
102 |       }
103 |     }
104 |     return ans;
105 |   } 
106 | 	else {
107 |     mexErrMsgTxt("float bitmap not uint8 or double");
108 | 		return NULL;
109 |   }
110 | }
111 | 
112 | // stack (x, y) to an integer by concatenate "yx" (assume y and x has at most 12 bit, or 4096 values)
113 | BITMAP *convert_field(Params *p, const mxArray *A, int bw, int bh, int &nclip, int trim_patch) {
114 |   nclip = 0;
115 |   int h = mxGetDimensions(A)[0];
116 |   int w = mxGetDimensions(A)[1];
117 | 	int offset = h * w;
118 | 	int ndims = mxGetNumberOfDimensions(A);
119 |   if (ndims != 3) {
120 |     char buf[256];
121 |     if (ndims == 1) {
122 |       sprintf(buf, "field dims != 3 (%d 1d array where nn field expected)", h);
123 |     } else if (ndims == 2) {
124 |       sprintf(buf, "field dims != 3 (%dx%d 2d array where nn field expected)", h, w);
125 |     } else {
126 |       sprintf(buf, "field dims != 3 (%d dimension array where nn field expected)", ndims);
127 |     }
128 |     mexErrMsgTxt(buf);
129 |   }
130 |   if (mxGetDimensions(A)[2] != 3) { mexErrMsgTxt("field channels != 3"); }
131 |   if (!mxIsInt32(A)) { mexErrMsgTxt("field is not int32"); }
132 | 
133 |   int bew = trim_patch ? (bw - p->patch_w + 1): bw;
134 |   int beh = trim_patch ? (bh - p->patch_w + 1): bh;
135 | 
136 |   unsigned int *data = (unsigned int *) mxGetData(A);
137 |   BITMAP *ann = create_bitmap(w, h);
138 |   //annd = create_bitmap(w, h);
139 |   for (int y = 0; y < h; y++) {
140 |     int *ann_row = (int *) ann->line[y];
141 |     //int *annd_row = (int *) annd->line[y];
142 |     for (int x = 0; x < w; x++) {
143 | 			unsigned int *base = data + y + x*h; 
144 |       int xp = base[0];
145 |       int yp = base[offset];
146 |       if ((unsigned) xp >= (unsigned) bew ||
147 |           (unsigned) yp >= (unsigned) beh) {
148 |         nclip++;
149 | 				clip_value<int>(&xp, 0, bew-1);
150 | 				clip_value<int>(&yp, 0, beh-1);
151 |       }
152 | 
153 |       //int dp = data[(y+x*h)+2*w*h];
154 |       ann_row[x] = XY_TO_INT(xp, yp);
155 |       //annd_row[x] = dp;
156 |     }
157 |   }
158 |   return ann;
159 | }
160 | 
161 | BITMAP *convert_winsize_field(Params *p, const mxArray *A, int w, int h) {
162 |   int ndims = mxGetNumberOfDimensions(A);
163 |   if (!( (ndims == 2)||((ndims == 3)&&(mxGetDimensions(A)[2] == 2))&&(w==mxGetDimensions(A)[1])&&(h==mxGetDimensions(A)[0]) )) {
164 | 		char buf[256];
165 | 	//sprintf(buf, "ndims=%d, mxGetDim(A)=[%d %d %d], [2 w h]=[2 %d %d] \n", ndims,mxGetDimensions(A)[2],mxGetDimensions(A)[1],mxGetDimensions(A)[0],h,w);
166 | 		sprintf(buf, "winsize field dims=%d (a [%dx%d] or [%dx%dx2] field of window size is expected)", ndims, h, w, h, w);
167 |     mexErrMsgTxt(buf);
168 |   }
169 |   if (!mxIsInt32(A)) { mexErrMsgTxt("winsize field is not int32"); }
170 | 
171 |   unsigned int *data = (unsigned int *) mxGetData(A);
172 | 	int offset = h * w;
173 |   BITMAP *awsz = create_bitmap(w, h);
174 |   char buf[256];
175 |   if (ndims == 2) {
176 | 		for (int y = 0; y < h; y++) {
177 | 			int *awsz_row = (int *) awsz->line[y];
178 | 			for (int x = 0; x < w; x++) {
179 | 				int wp = data[y+x*h];
180 | 				awsz_row[x] = XY_TO_INT(wp, wp);
181 | 			}
182 | 		}
183 |   } 
184 | 	else if ((ndims == 3)&&(mxGetDimensions(A)[2] == 2)) {
185 | 		for (int y = 0; y < h; y++) {
186 | 			int *awsz_row = (int *) awsz->line[y];
187 | 			for (int x = 0; x < w; x++) {
188 | 				unsigned int *base = data + y + x * h;
189 | 				int wp = base[0];
190 | 				int hp = base[offset];
191 | 				awsz_row[x] = XY_TO_INT(wp, hp);
192 | 			}
193 |     }
194 |   }
195 |   return awsz;
196 | }
197 | 
198 | mxArray *bitmap_to_array(BITMAP *a) {
199 |   mwSize dims[3] = { a->h, a->w, 3 };
200 |   mxArray *ans = mxCreateNumericArray(3, dims, mxUINT8_CLASS, mxREAL);
201 |   unsigned char *data = (unsigned char *) mxGetData(ans);
202 | 	int offset = a->w * a->h;
203 | 	int offset2 = offset << 1;
204 |   unsigned char *rchan = &data[0];
205 |   unsigned char *gchan = &data[offset];
206 |   unsigned char *bchan = &data[offset2];
207 |   for (int y = 0; y < a->h; y++) {
208 |     int *row = (int *) a->line[y];
209 |     for (int x = 0; x < a->w; x++) {
210 |       int c = row[x];
211 | 			int pos = y + x * a->h;
212 |       rchan[pos] = c&255;
213 |       gchan[pos] = (c>>8)&255;
214 |       bchan[pos] = (c>>16);
215 |     }
216 |   }
217 |   return ans;
218 | }
219 | 
220 | int mxStringEquals(const mxArray *A, const char *s) {
221 |   char buf[256];
222 |   if (!mxIsChar(A)) { return 0; }
223 |   if (mxGetString(A, buf, 255)) { return 0; }
224 |   return strcmp(s, buf) == 0;
225 | }
226 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/mexutil.h:
--------------------------------------------------------------------------------
 1 | 
 2 | #ifndef _mexutil_h
 3 | #define _mexutil_h
 4 | 
 5 | #include "allegro_emu.h"
 6 | #include "mex.h"
 7 | #include "nn.h"
 8 | #include "vecnn.h"
 9 | 
10 | BITMAP *convert_bitmap(const mxArray *A);
11 | BITMAP *convert_bitmapf(const mxArray *A);
12 | BITMAP *convert_field(Params *p, const mxArray *A, int bw, int bh, int &nclip, int trim_patch=1);
13 | BITMAP *convert_winsize_field(Params *p, const mxArray *A, int w, int h);
14 | mxArray *bitmap_to_array(BITMAP *a);
15 | int mxStringEquals(const mxArray *A, const char *s);
16 | 
17 | template<class T> 
18 | inline void clip_value(T *p, T low, T high) { 
19 | 	if(*p < low) *p = low; 
20 | 	else if(*p > high) *p = high; 
21 | }
22 | 
23 | // from MATLAB's column major to C++'s row major
24 | template<class T>
25 | VECBITMAP<T> *convert_vecbitmap(const mxArray *A) {
26 |   if (mxGetNumberOfDimensions(A) != 3) { mexErrMsgTxt("dims != 3"); }
27 | 
28 |   int h = mxGetDimensions(A)[0];
29 |   int w = mxGetDimensions(A)[1];
30 |   int n = mxGetDimensions(A)[2];
31 | 
32 |   VECBITMAP<T> *ans = new VECBITMAP<T>(w, h, n);
33 | 
34 |   int offset = w*h;
35 |   if (mxIsUint8(A)) {
36 |     unsigned char *data = (unsigned char *) mxGetData(A);
37 |     for (int y = 0; y < h; y++) {
38 |       for (int x = 0; x < w; x++) {
39 |         T *patch = ans->get(x, y);
40 |         unsigned char *pos0 = &data[y+x*h];
41 |         for (int i = 0; i < n; i++) {
42 |           patch[i] = pos0[offset*i];
43 |         }
44 |       }
45 |     }
46 |   } 
47 | 	else if (mxIsSingle(A)) {
48 |     float *data = (float *) mxGetData(A);
49 |     for (int y = 0; y < h; y++) {
50 |       for (int x = 0; x < w; x++) {
51 |         T *patch = ans->get(x, y);
52 |         float *pos0 = &data[y+x*h];
53 |         for (int i = 0; i < n; i++) {
54 |           patch[i] = pos0[offset*i];
55 |         }
56 |       }
57 |     }
58 |   } 
59 | 	else if (mxIsDouble(A)) {
60 |     double *data = (double *) mxGetData(A);
61 |     for (int y = 0; y < h; y++) {
62 |       for (int x = 0; x < w; x++) {
63 |         T *patch = ans->get(x, y);
64 |         double *pos0 = &data[y+x*h];
65 |         for (int i = 0; i < n; i++) {
66 |           patch[i] = pos0[offset*i];
67 |         }
68 |       }
69 |     }
70 |   } 
71 | 	else {
72 |     mexErrMsgTxt("bitmap not uint8, single, or double");
73 |   }
74 |   return ans;
75 | }
76 | 
77 | #endif
78 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/neural_patchmatch.m:
--------------------------------------------------------------------------------
 1 | function [C, field] = neural_patchmatch(A, B, A_f, B_f, patch_w)
 2 |     cores = 2;
 3 |     
 4 |     if cores==1
 5 |         algo = 'cpu';
 6 |     else
 7 |         algo = 'cputiled';
 8 |     end
 9 |     
10 |     field = nnmex(A_f, B_f, algo, patch_w, [], [], [], [], [], cores);
11 |     
12 |     C = votemex(B, field);
13 |     writeim(C, 'C.png')
14 |     
15 |     disp('done!')
16 | end 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/nn.h:
--------------------------------------------------------------------------------
  1 | 
  2 | /* Code for 3-channel input image. Warning: weight BITMAPs always encode 32-bit floats, not ints. */
  3 | 
  4 | #ifndef _nn_h
  5 | #define _nn_h
  6 | 
  7 | #include "allegro_emu.h"
  8 | #include <stdio.h>
  9 | #include <vector>
 10 | #include <limits.h>
 11 | #include <string.h>
 12 | #include <stdlib.h>
 13 | 
 14 | /* Set this to 0 if your compiler does have OpenMP support. */
 15 | #define USE_OPENMP             1
 16 | 
 17 | #if USE_OPENMP
 18 | #include <omp.h>
 19 | #endif
 20 | 
 21 | using namespace std;
 22 | 
 23 | /* --------------------------------------------------------------------
 24 |    Defines
 25 |    -------------------------------------------------------------------- */
 26 | 
 27 | #define IS_VERBOSE             0
 28 | #define SYNC_WRITEBACK         1
 29 | #define MAX_PATCH_W            32
 30 | 
 31 | #define AEW (a->w - p->patch_w + 1)
 32 | #define AEH (a->h - p->patch_w + 1)
 33 | #define BEW (b->w - p->patch_w + 1)
 34 | #define BEH (b->h - p->patch_w + 1)
 35 | 
 36 | #ifndef MAX
 37 | //template<class T> inline T MAX(T a, T b) { a > b ? a : b; }
 38 | //template<class T> inline T MIN(T a, T b) { a < b ? a : b; } 
 39 | #define MAX(a, b) ((a)>(b)?(a):(b))
 40 | #define MIN(a, b) ((a)<(b)?(a):(b))
 41 | #endif
 42 | 
 43 | /* --------------------------------------------------------------------
 44 |    Defaults
 45 |    -------------------------------------------------------------------- */
 46 | 
 47 | #define COHERENCE_WEIGHT        0.5
 48 | #define COMPLETE_WEIGHT         0.5
 49 | 
 50 | #define XY_TO_INT(x, y) (((y)<<12)|(x))
 51 | #define INT_TO_X(v) ((v)&((1<<12)-1))
 52 | #define INT_TO_Y(v) ((v)>>12)
 53 | #define XY_TO_INT_SHIFT 12
 54 | 
 55 | /* --------------------------------------------------------------------
 56 |    Randomized NN algorithm
 57 |    -------------------------------------------------------------------- */
 58 | 
 59 | #if !IS_VERBOSE
 60 | #ifdef printf
 61 | #undef printf
 62 | #endif
 63 | #define printf (void)
 64 | #define fflush (void)
 65 | #endif
 66 | 
 67 | class RecomposeParams;
 68 | class Params;
 69 | class RegionMasks;
 70 | 
 71 | #define ALGO_CPU             0
 72 | #define ALGO_GPUCPU          6
 73 | #define ALGO_FULLRAND        7
 74 | #define ALGO_CPUTILED        8
 75 | 
 76 | #define KNN_ALGO_HEAP        0
 77 | #define KNN_ALGO_AVOID       1
 78 | #define KNN_ALGO_PRINANGLE   2
 79 | #define KNN_ALGO_TOP1NN      3
 80 | #define KNN_ALGO_WINDOW      4
 81 | #define KNN_ALGO_KDTREE      5
 82 | #define KNN_ALGO_CHANGEK     6
 83 | #define KNN_ALGO_FLANN       7
 84 | 
 85 | #define VOTE_MEAN            0
 86 | #define VOTE_SUM             1
 87 | 
 88 | class Params { public:
 89 |   int algo;              /* Algorithm to use, one of ALGO_*. */
 90 |   
 91 |   /* Randomized NN algorithm parameters. */
 92 |   int patch_w;           /* Width and height of square patch. */
 93 |   int vec_len;           /* Length of vector if using vectorized NN algorithms (vecnn.h), for non-square patches and feature descriptors. */
 94 |   int nn_iters;          /* Iters of randomized NN algorithm. */
 95 |   int rs_max;            /* Maximum width for RS. */
 96 |   int rs_min;            /* Minimum width for RS. */
 97 |   double rs_ratio;       /* Ratio (< 1) of successive RS sizes. */
 98 |   double rs_iters;       /* RS iters per pixel.  1 => search all scales once. */
 99 |   int do_propagate;      /* Do propagation. */
100 |   int gpu_prop;          /* Maximum propagation distance for GPU algo. */
101 |   int xmin, ymin;        /* Min update region coord, or -1 for no box. */
102 |   int xmax, ymax;        /* Max update region coord, or -1 for no box. */
103 |   int resample_seamcarv; /* Resample via seam carving. */
104 |   int vote_algo;         /* Vote algorithm, one of VOTE_*. */
105 |   int prefer_coherent;   /* Prefer coherent regions, bool, default false. */
106 |   int allow_coherent;    /* This must be enabled for the previous flag to take effect. */
107 |   int cores;             /* If > 1, use OpenMP. */
108 |   int window_w;          /* Constraint search window width. */
109 |   int window_h;          /* Constraint search window height. */
110 |   int weight_r;          /* Multiplicative weights for R, G, B in distance computation. */
111 |   int weight_g;
112 |   int weight_b;
113 |   
114 |   /* Tree NN algorithm parameters. */
115 |   int pca_dim;           /* Tree PCA dim, INT_MAX for no PCA. */
116 |   double pca_var;        /* Fraction of total variance, e.g. 0.95 for 95%, negative to not use this param. */
117 |   float eps;             /* Tree epsilon. */
118 |   int kcoherence_k;      /* k for kcoherence. */
119 |   int kcoherence_iters;  /* Iters of kcoherence "propagation", 2 iters is Lefebre '95. */
120 |   int kcoherence_neighbors; /* k-coherence neighbors, 4 or 8. */
121 | 
122 |   int knn;
123 |   int knn_algo;
124 |   int restarts;
125 |   int enrich_iters;
126 |   int enrich_times;
127 |   int do_inverse_enrich;
128 |   int do_enrich;
129 | 
130 |   /* Defaults. */
131 |   Params()
132 |     :algo(ALGO_CPU),
133 |      patch_w(7),
134 |      vec_len(0),
135 |      nn_iters(5),
136 |      rs_max(INT_MAX),
137 |      rs_min(1),
138 |      rs_ratio(0.5),
139 |      rs_iters(1),
140 |      do_propagate(1),
141 |      gpu_prop(8),
142 |      xmin(-1), ymin(-1),
143 |      xmax(-1), ymax(-1),
144 |      resample_seamcarv(0),
145 |      vote_algo(VOTE_MEAN),
146 |      pca_dim(25),
147 |      pca_var(-1),
148 |      eps(2),
149 |      prefer_coherent(0),
150 |      allow_coherent(0),
151 |      cores(2),
152 |      window_w(INT_MAX),
153 |      window_h(INT_MAX),
154 |      weight_r(1),
155 |      weight_g(1),
156 |      weight_b(1),
157 |      kcoherence_k(2),
158 |      kcoherence_iters(2),
159 |      kcoherence_neighbors(8),
160 |      knn(0),
161 |      knn_algo(KNN_ALGO_HEAP),
162 |      restarts(1),
163 |      enrich_iters(0),
164 |      enrich_times(1),
165 |      do_inverse_enrich(1),
166 |      do_enrich(1)
167 |      { }
168 | };
169 | 
170 | void init_params(Params *p);
171 | void init_openmp(Params *p);
172 | void srand2(unsigned seed);
173 | 
174 | BITMAP *init_nn(Params *p, BITMAP *a, BITMAP *b, BITMAP *bmask=NULL, RegionMasks *region_masks=NULL, RegionMasks *amask=NULL, int trim_patch=1, BITMAP *ann_window=NULL, BITMAP *awinsize=NULL);
175 | BITMAP *init_dist(Params *p, BITMAP *a, BITMAP *b, BITMAP *ann, BITMAP *bmask=NULL, RegionMasks *region_masks=NULL, RegionMasks *amask=NULL);
176 | 
177 | void nn(Params *p, BITMAP *a, BITMAP *b,
178 |         BITMAP *ann, BITMAP *annd,
179 |         RegionMasks *amask=NULL, BITMAP *bmask=NULL,
180 |         int level=0, int em_iter=0, RecomposeParams *rp=NULL, int offset_iter=0, int update_type=0, int cache_b=0,
181 |         RegionMasks *region_masks=NULL, int tiles=-1, BITMAP *ann_window=NULL, BITMAP *awinsize=NULL);
182 | 
183 | class Box { 
184 | public:
185 |   int xmin, ymin, xmax, ymax;
186 | };
187 | 
188 | class RegionMasks { 
189 | public:
190 |   BITMAP *bmp;
191 |   Box box[256];
192 |   RegionMasks(Params *p, BITMAP *region_masks, int full=0, BITMAP *bmask=NULL);
193 | };
194 | 
195 | void destroy_region_masks(RegionMasks *m);
196 | 
197 | /* --------------------------------------------------------------------
198 |    Utility functions
199 |    -------------------------------------------------------------------- */
200 | 
201 | /* PRNG without global variable, pass nonzero seed as argument. */
202 | #define RANDI(u) (18000 * ((u) & 65535) + ((u) >> 16))
203 | 
204 | BITMAP *norm_image(double *accum, int w, int h);
205 | BITMAP *norm_image(int *accum, int w, int h);
206 | 
207 | int is_window(Params *p);
208 | 
209 | int window_constraint(Params *p, BITMAP *a, BITMAP *b, int ax, int ay, int bx, int by, BITMAP *ann_window=NULL, BITMAP *awinsize=NULL);
210 | 
211 | Box get_abox(Params *p, BITMAP *a, RegionMasks *amask, int trim_patch=1);
212 | 
213 | BITMAP *copy_image(BITMAP *a);
214 | 
215 | BITMAP *vote(Params *p, BITMAP *b,
216 |              BITMAP *ann, BITMAP *bnn=NULL,
217 |              BITMAP *bmask=NULL, BITMAP *bweight=NULL,
218 |              double coherence_weight=COHERENCE_WEIGHT, double complete_weight=COMPLETE_WEIGHT,
219 |              RegionMasks *amask=NULL, BITMAP *aweight=NULL, BITMAP *ainit=NULL, RegionMasks *region_masks=NULL, BITMAP *aconstraint=NULL, int mask_self_only=0);
220 | 
221 | int patch_dist(Params *p, BITMAP *a, int ax, int ay,
222 |                BITMAP *b, int bx, int by, int maxval=INT_MAX, RegionMasks *region_masks=NULL);
223 | 
224 | /* Clip votes to valid rectangle, return number of votes clipped. */
225 | int clip_nn(Params *p, BITMAP *ann, BITMAP *b);
226 | 
227 | void check_colors(BITMAP *bmp);
228 | void check_dists(Params *p, BITMAP *a, BITMAP *b, BITMAP *ann, BITMAP *annd, int max_dist=3, RegionMasks *amask=NULL);
229 | void check_nn(Params *p, BITMAP *ann, BITMAP *b, BITMAP *bmask=NULL, RegionMasks *amask=NULL, RegionMasks *region_masks=NULL);
230 | 
231 | void getnn(BITMAP *ann, int x, int y, int &xp, int &yp);
232 | 
233 | void minnn(Params *p, BITMAP *a, BITMAP *b, BITMAP *ann, BITMAP *annd, BITMAP *ann_prev, BITMAP *bmask, int level, int em_iter, RecomposeParams *rp=NULL, RegionMasks *region_masks=NULL, RegionMasks *amask=NULL, int ntiles=-1);
234 | 
235 | 
236 | class VECBITMAP_ARB { 
237 | public:
238 |   vector<unsigned> *data;
239 |   int w, h;
240 |   vector<unsigned> *get(int x, int y);
241 | };
242 | 
243 | VECBITMAP_ARB *create_vecbitmap_arb(int w, int h);
244 | void destroy_vecbitmap_arb(VECBITMAP_ARB *bmp);
245 | void save_vecbitmap_arb(const char *filename, VECBITMAP_ARB *bmp);
246 | void sort_vecbitmap_arb(VECBITMAP_ARB *bmp);
247 | 
248 | /* Parameters for high-level recomposition. */
249 | class RecomposeParams { public:
250 |   int minnn_optp_nn_iters;    /* Optimized params: NN iters for previous offsets. */
251 |   int minnn_optp_rs_max;      /* Optimized params: Max RS for previous offsets. */
252 | 
253 |   RecomposeParams()
254 |     :minnn_optp_nn_iters(2),
255 |      minnn_optp_rs_max(1) {}
256 | };
257 | 
258 | #endif
259 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/nnmex.m:
--------------------------------------------------------------------------------
 1 | %function ann = nnmex(A, B, [algo='cpu'], [patch_w=7], [nn_iters=5], [rs_max=100000], [rs_min=1], [rs_ratio=0.5], [rs_iters=1.0], [cores=2], [bmask=NULL]...
 2 | % [win_size=[INT_MAX INT_MAX]], [nnfield_prev=[]], [nnfield_prior=[]], [prior_winsize=[]], [knn=1], [scalerange=4])
 3 | %      (Pass [] to leave a parameter at its default).
 4 | %
 5 | %MATLAB Interface for PatchMatch + Generalized PatchMatch
 6 | %
 7 | %Input signals A, B, are 3D arrays of size either hxwx3 (image mode) or hxwxn (descriptor mode).
 8 | %  In image mode, the input images are broken up into overlapping patches of size patch_w x patch_w
 9 | %    (allowed data types: uint8, or floats in [0, 1], which are quantized).
10 | %  In descriptor mode, the inputs have an n dimensional descriptor at each (x, y) coordinate
11 | %    (allowed data types: uint8, or floats of any range, which are not quantized).
12 | %    Pass a patch width of 1 unless you want these descriptors to be stacked in a larger patch_w^2 x n descriptor prior to distance comparison.
13 | %
14 | %Returns 'ann' - NN field (hxwx3, int32) mapping A -> B.
15 | %Channel 1 is x coord, channel 2 is y coord, channel 3 is squared L2 distance.
16 | % (In descriptor mode with float input, the output NN field reports all zeros in channel 3 for the output.)
17 | % (When searching over all rotations+scales, the output NN field has channel 4 as theta 0...2pi, and channel 5 as scale. The patches in
18 | %  image A are not rotated or scaled; the patches in image B are rotated and scaled around their center coordinate as if they had scale 1).
19 | %
20 | %The default distance metric to compare patches/descriptors is L2. To use L1 distance, set USE_L1 to 1 in patch.h.
21 | %
22 | %Options are:
23 | %algo x         - One of 'cpu', 'gpucpu', 'cputiled', 'rotscale' (search over all rotations and scales), 'enrich' (an acceleration for kNN when both images are the same)
24 | %patch_w p      - Width (and height) of patch, currently support sizes up to 32
25 | %nn_iters n     - Iters of randomized NN algo
26 | %rs_max w       - Maximum width for RS
27 | %rs_min w       - Minimum width for RS
28 | %rs_ratio r     - Ratio (< 1) of successive RS sizes
29 | %rs_iters n     - Iters (double precision) of RS algorithm
30 | %cores n        - Cores to run GPU-CPU algorithm on
31 | %bmask [hxwx3]  - "1" indicates a hole
32 | %win_size [w h] - Size of search window [2*h+1 x 2*w+1] around the input pixel location 
33 | %				(interpolated linearly to the output coordinates in case of different
34 | %				sizes). Slower but allows to limit the search space locally.
35 | %ann_prev       - (hxwx3, double) initial mapping A -> B. The final result is
36 | %				the minimum distance between initial mapping and random initialization + a
37 | %				few final iterations. The squared distance channel in ann_prev is not used.
38 | %ann_prior      - (hxwx2) field that constrains the search in a local window around the locations in B defined by the ann_prior field.
39 | %ann_winsize    - (hxwx2) array matching ann_prior that defines locally the window size (per pixel) - first channel for window width, second channel for the height.
40 | %knn            - Defines number of k-Nearest Neighbors to return. Returns a NNF of size h x w x 3 x k.
41 | %scalerange     - When searching over rotations+scales, patches in image B can have size in [1/scalerange, scalerange].
42 | %
43 | %------------------------------------------------------------------------%
44 | % Copyright 2008-2010 Adobe Systems Inc. and Connelly Barnes
45 | %
46 | % For noncommercial use only.
47 | %
48 | % Please cite the appropriate paper(s) if used in research:
49 | %
50 | % - PatchMatch: A Randomized Correspondence Algorithm for Structural Image Editing.
51 | %   Connelly Barnes, Eli Shechtman, Adam Finkelstein, and Dan B Goldman.
52 | %   ACM Transactions on Graphics (Proc. SIGGRAPH), 28(3), 2009
53 | %   http://www.cs.princeton.edu/gfx/pubs/Barnes_2009_PAR/
54 | %
55 | % - The Generalized PatchMatch Correspondence Algorithm
56 | %   Connelly Barnes, Eli Shechtman, Dan B Goldman, and Adam Finkelstein.
57 | %   Proc. European Conference on Computer Vision 2010
58 | %   http://www.cs.princeton.edu/gfx/pubs/Barnes_2010_TGP/index.php
59 | %   (k-Nearest Neighbors, Rotations+Scales, Descriptor Matching)
60 | %
61 | % Main contact: csbarnes@cs.princeton.edu  (Connelly)
62 | % Version: 2.0, 2010-11-05
63 | %------------------------------------------------------------------------%
64 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/nnmex.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/patchmatch-2.0/nnmex.mexa64


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/nnmex.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/patchmatch-2.0/nnmex.mexw64


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/patch.h:
--------------------------------------------------------------------------------
  1 | 
  2 | /* Patch distance templates. */
  3 | 
  4 | // Three groups of functions
  5 | // fast_patch_dist:			taking adata, b_bitmap, and do early termination according to maxval
  6 | // fast_patch_nobranch:	taking adata, b_bitmap, but NO early termination
  7 | // patch_dist_ab:				taking a_bitmap, b_bitmap, and do early termination according to maxval
  8 | // 
  9 | // Use template specialization to speed up for smaller patch sizes
 10 | //
 11 | 
 12 | #ifndef _patch_h
 13 | #define _patch_h
 14 | 
 15 | #include "allegro_emu.h"
 16 | #include "nn.h"
 17 | 
 18 | #define USE_L1 0
 19 | 
 20 | #define ALLOC_ADATA int adata[PATCH_W*PATCH_W];
 21 | 
 22 | #if USE_L1
 23 | #define DELTA_TERM_R(dr) (abs(dr))
 24 | #define DELTA_TERM_RGB_ex(dr, dg, db) (abs(dr)+abs(dg)+abs(db))
 25 | #else
 26 | #define DELTA_TERM_R(dr) ((dr)*(dr))
 27 | #define DELTA_TERM_RGB_ex(dr, dg, db) (dr*dr+dg*dg+db*db)
 28 | #endif
 29 | #define DELTA_TERM DELTA_TERM_RGB_ex(dr, dg, db)
 30 | #define DELTA_TERM_RGB(dr, dg, db) DELTA_TERM_RGB_ex(dr, dg, db)
 31 | 
 32 | template<int TPATCH_W, int IS_WINDOW>
 33 | int fast_patch_dist(int *adata, BITMAP *b, int bx, int by, int maxval, Params *p) {
 34 |   if (IS_WINDOW) {
 35 |     int ans = 0;
 36 |     for (int dy = 0; dy < TPATCH_W; dy++) {
 37 |       int *row2 = ((int *) b->line[by+dy])+bx;
 38 |       for (int dx = 0; dx < TPATCH_W; dx++) {
 39 |         unsigned int c1 = adata[dx];
 40 |         unsigned int c2 = row2[dx];
 41 |         int dr = (c1&255)-(c2&255);
 42 |         int dg = ((c1>>8)&255)-((c2>>8)&255);
 43 |         int db = (c1>>16)-(c2>>16);
 44 |         dr *= p->weight_r;
 45 |         dg *= p->weight_g;
 46 |         db *= p->weight_b;
 47 |         ans += dr*dr+dg*dg+db*db;
 48 |         if (ans > maxval) { return ans; } // early termination, the only difference from fast_patch_nobranch
 49 |       }
 50 |       adata += TPATCH_W; // trick here to advance pointer adata
 51 |     }
 52 |     return ans;
 53 |   } // end of (IS_WINDOW == true)
 54 | 	else {
 55 |     int ans = 0;
 56 |     for (int dy = 0; dy < TPATCH_W; dy++) {
 57 |       int *row2 = ((int *) b->line[by+dy])+bx;
 58 |       for (int dx = 0; dx < TPATCH_W; dx++) {
 59 |         unsigned int c1 = adata[dx];
 60 |         unsigned int c2 = row2[dx];
 61 |         int dr = (c1&255)-(c2&255);
 62 |         int dg = ((c1>>8)&255)-((c2>>8)&255);
 63 |         int db = (c1>>16)-(c2>>16);
 64 |         ans += dr*dr+dg*dg+db*db;
 65 |         if (ans > maxval) { return ans; }
 66 |       }
 67 |       adata += TPATCH_W;
 68 |     }
 69 |     return ans;
 70 |   }
 71 | }
 72 | 
 73 | 
 74 | // !!!Note: this speeds up greatly
 75 | template<>
 76 | int fast_patch_dist<1, 0>(int *adata, BITMAP *b, int bx, int by, int maxval, Params *p);
 77 | 
 78 | template<>
 79 | int fast_patch_dist<2, 0>(int *adata, BITMAP *b, int bx, int by, int maxval, Params *p);
 80 | 
 81 | template<>
 82 | int fast_patch_dist<3, 0>(int *adata, BITMAP *b, int bx, int by, int maxval, Params *p);
 83 | 
 84 | template<>
 85 | int fast_patch_dist<4, 0>(int *adata, BITMAP *b, int bx, int by, int maxval, Params *p);
 86 | 
 87 | template<>
 88 | int fast_patch_dist<5, 0>(int *adata, BITMAP *b, int bx, int by, int maxval, Params *p);
 89 | 
 90 | template<>
 91 | int fast_patch_dist<6, 0>(int *adata, BITMAP *b, int bx, int by, int maxval, Params *p);
 92 | 
 93 | template<>
 94 | int fast_patch_dist<7, 0>(int *adata, BITMAP *b, int bx, int by, int maxval, Params *p);
 95 | 
 96 | // !!!notice that "err", "xbest", "ybest" might be changed in this function
 97 | template<int PATCH_W, int IS_MASK, int IS_WINDOW>
 98 | void attempt_n(int &err, int &xbest, int &ybest, int *adata, BITMAP *b, int bx, int by, BITMAP *bmask, RegionMasks *region_masks, int src_mask, Params *p) {
 99 |   if ((bx != xbest || by != ybest) &&
100 |       (unsigned) bx < (unsigned) (b->w-PATCH_W+1) &&
101 |       (unsigned) by < (unsigned) (b->h-PATCH_W+1)) 
102 | 	{
103 |     if (IS_MASK && region_masks && src_mask != ((int *) region_masks->bmp->line[by])[bx]) { return; }
104 |     if (IS_MASK && bmask && ((int *) bmask->line[by])[bx]) { return; }
105 |     int current = fast_patch_dist<PATCH_W, IS_WINDOW>(adata, b, bx, by, err, p);
106 |     if (current < err) {
107 |       err = current;
108 |       xbest = bx;
109 |       ybest = by;
110 |     }
111 |   }
112 | }
113 | 
114 | template<int TPATCH_W, int IS_WINDOW>
115 | int fast_patch_nobranch(int *adata, BITMAP *b, int bx, int by, Params *p) {
116 |   //if (IS_MASK && bmask && ((int *) bmask->line[by])[bx]) { return INT_MAX; }
117 |   if (IS_WINDOW) {
118 |     int ans = 0;
119 |     for (int dy = 0; dy < TPATCH_W; dy++) {
120 |       int *row2 = ((int *) b->line[by+dy])+bx;
121 |       for (int dx = 0; dx < TPATCH_W; dx++) {
122 |         unsigned int c1 = adata[dx];
123 |         unsigned int c2 = row2[dx];
124 |         int dr = (c1&255)-(c2&255);
125 |         int dg = ((c1>>8)&255)-((c2>>8)&255);
126 |         int db = (c1>>16)-(c2>>16);
127 |         dr *= p->weight_r;
128 |         dg *= p->weight_g;
129 |         db *= p->weight_b;
130 |         ans += dr*dr+dg*dg+db*db;
131 |       }
132 |       adata += TPATCH_W; // this is the trick!!!
133 |     }
134 |     return ans;
135 |   } else {
136 |     int ans = 0;
137 |     for (int dy = 0; dy < TPATCH_W; dy++) {
138 |       int *row2 = ((int *) b->line[by+dy])+bx;
139 |       for (int dx = 0; dx < TPATCH_W; dx++) {
140 |         unsigned int c1 = adata[dx];
141 |         unsigned int c2 = row2[dx];
142 |         int dr = (c1&255)-(c2&255);
143 |         int dg = ((c1>>8)&255)-((c2>>8)&255);
144 |         int db = (c1>>16)-(c2>>16);
145 |         ans += dr*dr+dg*dg+db*db;
146 |       }
147 |       adata += TPATCH_W;
148 |     }
149 |     return ans;
150 |   }
151 | }
152 | 
153 | template<>
154 | int fast_patch_nobranch<1, 0>(int *adata, BITMAP *b, int bx, int by, Params *p);
155 | 
156 | template<>
157 | int fast_patch_nobranch<2, 0>(int *adata, BITMAP *b, int bx, int by, Params *p);
158 | 
159 | template<>
160 | int fast_patch_nobranch<3, 0>(int *adata, BITMAP *b, int bx, int by, Params *p);
161 | 
162 | template<>
163 | int fast_patch_nobranch<4, 0>(int *adata, BITMAP *b, int bx, int by, Params *p);
164 | 
165 | template<>
166 | int fast_patch_nobranch<5, 0>(int *adata, BITMAP *b, int bx, int by, Params *p);
167 | 
168 | template<>
169 | int fast_patch_nobranch<6, 0>(int *adata, BITMAP *b, int bx, int by, Params *p);
170 | 
171 | template<>
172 | int fast_patch_nobranch<7, 0>(int *adata, BITMAP *b, int bx, int by, Params *p);
173 | 
174 | template<int TPATCH_W, int IS_WINDOW, int HAS_MASKS>
175 | int patch_dist_ab(Params *p, BITMAP *a, int ax, int ay, BITMAP *b, int bx, int by, int maxval, RegionMasks *region_masks) {
176 |   if (region_masks && ((int *) region_masks->bmp->line[ay])[ax] != ((int *) region_masks->bmp->line[by])[bx]) { return INT_MAX; }
177 |   
178 |   if (IS_WINDOW) {
179 |     int ans = 0;
180 |     for (int dy = 0; dy < TPATCH_W; dy++) {
181 |       int *row1 = ((int *) a->line[ay+dy])+ax;
182 |       int *row2 = ((int *) b->line[by+dy])+bx;
183 |       for (int dx = 0; dx < TPATCH_W; dx++) {
184 |         int c1 = row1[dx];
185 |         int c2 = row2[dx];
186 |         int dr = (c1&255)-(c2&255);
187 |         int dg = ((c1>>8)&255)-((c2>>8)&255);
188 |         int db = (c1>>16)-(c2>>16);
189 |         dr *= p->weight_r;
190 |         dg *= p->weight_g;
191 |         db *= p->weight_b;
192 |         ans += dr*dr+dg*dg+db*db;
193 |         if (ans > maxval) { return ans; }
194 |       }
195 |     }
196 |     return ans;
197 |   } else {
198 |     int ans = 0;
199 |     for (int dy = 0; dy < TPATCH_W; dy++) {
200 |       int *row1 = ((int *) a->line[ay+dy])+ax;
201 |       int *row2 = ((int *) b->line[by+dy])+bx;
202 |       for (int dx = 0; dx < TPATCH_W; dx++) {
203 |         int c1 = row1[dx];
204 |         int c2 = row2[dx];
205 |         int dr = (c1&255)-(c2&255);
206 |         int dg = ((c1>>8)&255)-((c2>>8)&255);
207 |         int db = (c1>>16)-(c2>>16);
208 |         ans += dr*dr+dg*dg+db*db;
209 |         if (ans > maxval) { return ans; }
210 |       }
211 |     }
212 |     return ans;
213 |   }
214 | }
215 | 
216 | template<>
217 | int patch_dist_ab<1, 0, 0>(Params *p, BITMAP *a, int ax, int ay, BITMAP *b, int bx, int by, int maxval, RegionMasks *region_masks);
218 | 
219 | template<>
220 | int patch_dist_ab<2, 0, 0>(Params *p, BITMAP *a, int ax, int ay, BITMAP *b, int bx, int by, int maxval, RegionMasks *region_masks);
221 | 
222 | template<>
223 | int patch_dist_ab<3, 0, 0>(Params *p, BITMAP *a, int ax, int ay, BITMAP *b, int bx, int by, int maxval, RegionMasks *region_masks);
224 | 
225 | template<>
226 | int patch_dist_ab<4, 0, 0>(Params *p, BITMAP *a, int ax, int ay, BITMAP *b, int bx, int by, int maxval, RegionMasks *region_masks);
227 | 
228 | template<>
229 | int patch_dist_ab<5, 0, 0>(Params *p, BITMAP *a, int ax, int ay, BITMAP *b, int bx, int by, int maxval, RegionMasks *region_masks);
230 | 
231 | template<>
232 | int patch_dist_ab<6, 0, 0>(Params *p, BITMAP *a, int ax, int ay, BITMAP *b, int bx, int by, int maxval, RegionMasks *region_masks);
233 | 
234 | template<>
235 | int patch_dist_ab<7, 0, 0>(Params *p, BITMAP *a, int ax, int ay, BITMAP *b, int bx, int by, int maxval, RegionMasks *region_masks);
236 | 
237 | #endif
238 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/readme.txt:
--------------------------------------------------------------------------------
 1 | 
 2 | --------------------------------------------------------------------------------------------------
 3 | 
 4 | PatchMatch -- Core matching algorithm only
 5 | MATLAB Mex Version 2.0 (2010-11-05)
 6 | 
 7 |   By Connelly Barnes
 8 |   Copyright 2008-2010 Adobe Systems Inc and Connelly Barnes
 9 |   Licensed by Adobe for noncommercial research use only.
10 | 
11 | --------------------------------------------------------------------------------------------------
12 | Background
13 | --------------------------------------------------------------------------------------------------
14 | 
15 | This code implements a fast randomized matching algorithm described in two publications as part of
16 | my Ph.D. thesis at Princeton.
17 | 
18 | The algorithm solves the following problem: For each patch (a small fixed size rectangular region,
19 | e.g. 7x7) in image A, find the nearest patch in image B, where "nearest" is defined as say the L2
20 | distance between corresponding RGB tuples. Our algorithm converges quickly to an approximate
21 | solution. In our original publication we find only 1 nearest neighbor, for patches that translate
22 | only. In our later work (Generalized PatchMatch) we extend to k-Nearest Neighbors (k-NN), and allow
23 | patches to rotate+scale, and match arbitrary descriptors (tuples of an arbitrary dimension rather
24 | than just RGB, e.g. one can match densely computed SIFT descriptors).
25 | 
26 | For more information on the problem we are solving and our solution see:
27 | 
28 |  - PatchMatch: A Randomized Correspondence Algorithm for Structural Image Editing
29 |    SIGGRAPH 2009, Connelly Barnes, Eli Shechtman, Adam Finkelstein, Dan B Goldman
30 |    http://www.cs.princeton.edu/gfx/pubs/Barnes_2009_PAR/index.php
31 | 
32 |  - The Generalized PatchMatch Correspondence Algorithm
33 |    ECCV 2010, Connelly Barnes, Eli Shechtman, Dan B Goldman, Adam Finkelstein
34 |    http://www.cs.princeton.edu/gfx/pubs/Barnes_2010_TGP/index.php
35 | 
36 | Please cite these paper(s) if you use this code in an academic publication.
37 | 
38 | --------------------------------------------------------------------------------------------------
39 | Contents
40 | --------------------------------------------------------------------------------------------------
41 | 
42 |  - For a portable, unoptimized, but very easy to understand PatchMatch code (200 lines, only 100
43 |    in the core algorithm), see: pm_minimal.cpp. This can be built without any dependencies, and
44 |    runs only requiring that ImageMagick be installed on your Windows/Mac/Unix machine.
45 | 
46 |  - For an optimized and more powerful PatchMatch, build the MATLAB interface:
47 | 
48 |    Build: Use build_windows.bat / build_mac.sh / build_unix.sh for your system
49 |    (Known to work on Windows XP, Vista, Mac OS X, and Linux, after varying amounts of fighting with the compiler).
50 |    (Disable optimizations if you're just trying to get it to build, this will help speed up your build process).
51 |    (OpenMP is used, but not required -- set USE_OPENMP in nn.h to 0 if your compiler does not support OpenMP)
52 | 
53 |    Usage: do 'help nnmex' or 'help votemex' in MATLAB, or run test_mex.m, test_rot_scale.m, test_descriptor_mex.m, or test_knn.m.
54 | 
55 |    For efficiency, use the 'cputiled' algorithm and set the cores argument to the number of processor cores on your system.
56 | 
57 | --------------------------------------------------------------------------------------------------
58 | Version History
59 | --------------------------------------------------------------------------------------------------
60 | 
61 |  * Wish list (to be added soon):
62 |    - Window constraints for kNN matching, or minimal distance between the kNN matches, to keep matches from being in nearby spatial locations.
63 |    - Examples: Object detection
64 |    - C commandline interface (not requiring MATLAB)
65 |    - Further optimizations (SSE, precomputed random search samples)
66 | 
67 |  * Version 2.0 (2010-11-05)
68 |    Connelly Barnes
69 |    - Added features from "The Generalized PatchMatch Correspondence Algorithm"
70 |    - Exposed k-Nearest Neighbor matching, matching across rotations+scales, and enrichment (a feature which accelerates convergence of kNN)
71 |    - Fixed multicore tiled algorithm to not have contention issues.
72 |    - Exposed min and max scale and rotation as parameters for rotation+scale matching.
73 |    - Minimal 200 line implementation of PatchMatch, with no build dependencies, provided in pm_minimal.cpp.
74 | 
75 |  * Version 1.1 (2010-06-30)
76 |    Xiaobai Chen
77 |    - New solution file "mex.sln" with two projects "nnmex" and "votemex" (important to set /openmp, otherwise must disable those omp_* calls)
78 |    - nnmex with bmask (changed the interface of nnmex)
79 |    - "clip_value" function to replace range examination code in mexutil.cpp and mexutil.h
80 |    - Added specialized templates for larger patches (up to 32)
81 |    - Need to guarantee patch size is less than the image size (no guarantee in the C++ code)
82 |    - New descriptor mode to support patches
83 |    - Re-implemented functions start with "XC", places with minor changes are not always marked
84 |    - Updated nnmex.m and votemex.m
85 | 
86 |  * Version 1.0 (2009-10-23)
87 |    Connelly Barnes Initial Release
88 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/simnn.h:
--------------------------------------------------------------------------------
 1 | 
 2 | /* PatchMatch with similarity transform of patches (rotation+scale). */
 3 | 
 4 | #ifndef _simnn_h
 5 | #define _simnn_h
 6 | 
 7 | #include "nn.h"
 8 | 
 9 | /*
10 | #define ANGLE_SHIFT XY_TO_INT_SHIFT
11 | #define NUM_ANGLES (1<<ANGLE_SHIFT)
12 | #define SCALE_SHIFT XY_TO_INT_SHIFT
13 | #define NUM_SCALES (1<<SCALE_SHIFT)
14 | #define SCALE_MIN 1.0
15 | #define SCALE_MAX 1.0
16 | */
17 | 
18 | #define ANGLE_SHIFT XY_TO_INT_SHIFT
19 | #define NUM_ANGLES (1<<ANGLE_SHIFT)
20 | #define SCALE_SHIFT XY_TO_INT_SHIFT
21 | #define NUM_SCALES (1<<SCALE_SHIFT)
22 | //#define SCALE_MIN 0.5
23 | //#define SCALE_MAX 2.0
24 | #define SCALE_UNITY (NUM_SCALES/2)      /* exp(log(SCALE_MIN)+(log(SCALE_MAX)-log(SCALE_MIN))*SCALE_UNITY*1.0/NUM_SCALES) should be exactly 1.0. */
25 | 
26 | class XFORM { 
27 | public:
28 |   int x0, y0, dxdu, dydu, dxdv, dydv;   /* Coords left shifted by 16. */
29 | };
30 | 
31 | void init_xform_tables(double SCALE_MIN=0.5, double SCALE_MAX=2.0, int force_init=0);
32 | XFORM get_xform(Params *p, int x, int y, int scale, int theta);  /* x and y not left shifted. */
33 | 
34 | void getpixel_bilin(BITMAP *bimg, int bx, int by, int &r, int &g, int &b);  /* Coords left shifted by 16. */
35 | 
36 | BITMAP *sim_init_nn(Params *p, BITMAP *a, BITMAP *b, BITMAP *&ann_sim);
37 | BITMAP *sim_init_dist(Params *p, BITMAP *a, BITMAP *b, BITMAP *ann, BITMAP *ann_sim);
38 | 
39 | void sim_nn(Params *p, BITMAP *a, BITMAP *b,
40 |             BITMAP *ann, BITMAP *ann_sim, BITMAP *annd,
41 |             RegionMasks *amask=NULL, BITMAP *bmask=NULL,
42 |             int level=0, int em_iter=0, RecomposeParams *rp=NULL, int offset_iter=0, int update_type=0, int cache_b=0,
43 |             RegionMasks *region_masks=NULL, int tiles=-1);
44 | 
45 | BITMAP *sim_vote(Params *p, BITMAP *b,
46 | 						BITMAP *ann, BITMAP *ann_sim, BITMAP *bnn=NULL, BITMAP *bnn_sim=NULL,
47 | 						BITMAP *bmask=NULL, BITMAP *bweight=NULL,
48 | 						double coherence_weight=COHERENCE_WEIGHT, double complete_weight=COMPLETE_WEIGHT,
49 | 						RegionMasks *amask=NULL, BITMAP *aweight=NULL, BITMAP *ainit=NULL, RegionMasks *region_masks=NULL, BITMAP *aconstraint=NULL, int mask_self_only=0);
50 | 
51 | #endif
52 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/simpatch.h:
--------------------------------------------------------------------------------
  1 | 
  2 | /* Patch distance templates for similarity transform (rotation+scale). */
  3 | 
  4 | #ifndef _simpatch_h
  5 | #define _simpatch_h
  6 | 
  7 | #include "patch.h"
  8 | #include "simnn.h"
  9 | 
 10 | // Turn one of these on. The fastest and most accurate way to sample is actually to nearest neighbor sample from a bilinearly upsampled image, but that's not implemented here.
 11 | #define SAMPLE_NN             1
 12 | #define SAMPLE_BILINEAR_EXACT 0
 13 | 
 14 | template<int TPATCH_W, int DO_BRANCH>
 15 | int sim_fast_patch_dist(int *adata, BITMAP *b, XFORM bpos, int maxval) {
 16 |   /* Do bounds checking outside the inner loop */
 17 |   int ul_x = bpos.x0;
 18 |   int ul_y = bpos.y0;
 19 |   int ur_x = bpos.x0+bpos.dxdu*(TPATCH_W-1);
 20 |   int ur_y = bpos.y0+bpos.dydu*(TPATCH_W-1);
 21 |   int ll_x = bpos.x0+bpos.dxdv*(TPATCH_W-1);
 22 |   int ll_y = bpos.y0+bpos.dydv*(TPATCH_W-1);
 23 |   int lr_x = ll_x+bpos.dxdu*(TPATCH_W-1);
 24 |   int lr_y = ll_y+bpos.dydu*(TPATCH_W-1);
 25 |   int bw16 = (b->w-1)<<16, bh16 = (b->h-1)<<16;
 26 |   if ((unsigned) ul_x >= (unsigned) bw16 ||
 27 |       (unsigned) ul_y >= (unsigned) bh16 ||
 28 |       (unsigned) ur_x >= (unsigned) bw16 ||
 29 |       (unsigned) ur_y >= (unsigned) bh16 ||
 30 |       (unsigned) ll_x >= (unsigned) bw16 ||
 31 |       (unsigned) ll_y >= (unsigned) bh16 ||
 32 |       (unsigned) lr_x >= (unsigned) bw16 ||
 33 |       (unsigned) lr_y >= (unsigned) bh16) { return INT_MAX-4096; }
 34 | 
 35 |   int ans = 0;
 36 |   int bx_row = bpos.x0, by_row = bpos.y0;
 37 | #if SAMPLE_NN
 38 |   bx_row += 32768;
 39 |   by_row += 32768;
 40 | #endif
 41 |   for (int dy = 0; dy < TPATCH_W; dy++) {
 42 |     int bx = bx_row, by = by_row;
 43 |     for (int dx = 0; dx < TPATCH_W; dx++) {
 44 |       unsigned int c1 = adata[dx];
 45 |       int r2, g2, b2;
 46 | #if SAMPLE_BILINEAR_EXACT
 47 | //      getpixel_bilin(b, bx, by, r2, g2, b2);   // A slower and safer method is to do bounds checking in the inner loop
 48 |       int bxi = bx>>16, byi = by>>16;
 49 |       int bxf = bx&((1<<16)-1), byf = by&((1<<16)-1);
 50 | 
 51 |       int *row1 = ((int *) b->line[byi])+bxi;
 52 |       int *row2 = ((int *) b->line[byi+1])+bxi;
 53 |       int cul = row1[0], cur = row1[1];
 54 |       int cll = row2[0], clr = row2[1];
 55 | 
 56 |       int rul = cul&255, rur = cur&255;
 57 |       int rll = cll&255, rlr = clr&255;
 58 | 
 59 |       int gul = (cul>>8)&255, gur = (cur>>8)&255;
 60 |       int gll = (cll>>8)&255, glr = (clr>>8)&255;
 61 | 
 62 |       int bul = cul>>16, bur = cur>>16;
 63 |       int bll = cll>>16, blr = clr>>16;
 64 | 
 65 |       int rt = rul+(((rur-rul)*bxf)>>16);
 66 |       int rb = rll+(((rlr-rll)*bxf)>>16);
 67 |       r2 = rt+(((rb-rt)*byf)>>16);
 68 | 
 69 |       int gt = gul+(((gur-gul)*bxf)>>16);
 70 |       int gb = gll+(((glr-gll)*bxf)>>16);
 71 |       g2 = gt+(((gb-gt)*byf)>>16);
 72 | 
 73 |       int bt = bul+(((bur-bul)*bxf)>>16);
 74 |       int bb = bll+(((blr-bll)*bxf)>>16);
 75 |       b2 = bt+(((bb-bt)*byf)>>16);
 76 | #else
 77 |       int c2 = ((int *) b->line[(by)>>16])[(bx)>>16];
 78 |       r2 = (c2&255);
 79 |       g2 = (c2>>8)&255;
 80 |       b2 = (c2>>16);
 81 | #endif
 82 |       int dr = (c1&255)-r2;
 83 |       int dg = ((c1>>8)&255)-g2;
 84 |       int db = (c1>>16)-b2;
 85 |       ans += DELTA_TERM; //dr*dr+dg*dg+db*db;
 86 |       if (DO_BRANCH && ans > maxval) { return ans; }
 87 |       bx += bpos.dxdu;
 88 |       by += bpos.dydu;
 89 |     }
 90 |     adata += TPATCH_W;
 91 |     bx_row += bpos.dxdv;
 92 |     by_row += bpos.dydv;
 93 |   }
 94 |   return ans;
 95 | }
 96 | 
 97 | template<int PATCH_W>
 98 | void sim_attempt_n(int &err, int &xbest, int &ybest, int &sbest, int &tbest, int *adata, BITMAP *b, XFORM bpos, int bx, int by, int bs, int bt, Params *p) {
 99 |   //int h = PATCH_W/2;
100 |   if ((bx != xbest || by != ybest || bs != sbest || bt != tbest) &&
101 |       (unsigned) (bx) < (unsigned) (b->w-PATCH_W+1) &&
102 |       (unsigned) (by) < (unsigned) (b->h-PATCH_W+1)) 
103 | 	{
104 |     //XFORM bpos = get_xform(p, bx, by, bs, bt);
105 |     int current = sim_fast_patch_dist<PATCH_W, 1>(adata, b, bpos, err);
106 |     if (current < err) {
107 |       err = current;
108 |       xbest = bx;
109 |       ybest = by;
110 |       sbest = bs;
111 |       tbest = bt;
112 |     }
113 |   }
114 | }
115 | 
116 | template<int TPATCH_W, int DO_BRANCH>
117 | int sim_patch_dist_ab(Params *p, BITMAP *a, int ax, int ay, BITMAP *b, int bx, int by, int bs, int bt, int maxval) {
118 |   int adata[TPATCH_W*TPATCH_W];
119 |   int *ptr = adata;
120 |   for (int dy = 0; dy < TPATCH_W; dy++) {
121 |     int *row = ((int *) a->line[ay+dy])+ax;
122 |     for (int dx = 0; dx < TPATCH_W; dx++) {
123 |       *ptr++ = *row++;
124 |     }
125 |   }
126 |   XFORM bpos = get_xform(p, bx, by, bs, bt);
127 |   return sim_fast_patch_dist<TPATCH_W, DO_BRANCH>(adata, b, bpos, maxval);
128 | }
129 | 
130 | #endif
131 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/test_descriptor_mex.m:
--------------------------------------------------------------------------------
  1 | 9i8u%------------------------------------------------------------------------%
  2 | % Copyright 2008-2009 Adobe Systems Inc., for noncommercial use only.
  3 | % Citation:
  4 | %   Connelly Barnes, Eli Shechtman, Adam Finkelstein, and Dan B Goldman.
  5 | %   PatchMatch: A Randomized Correspondence Algorithm for Structural Image
  6 | %   Editing. ACM Transactions on Graphics (Proc. SIGGRAPH), 28(3), 2009
  7 | %   http://www.cs.princeton.edu/gfx/pubs/Barnes_2009_PAR/
  8 | % Main contact: csbarnes@cs.princeton.edu  (Connelly)
  9 | % Version: 1.0, 21-June-2008
 10 | %------------------------------------------------------------------------%
 11 | 
 12 | % Test 'image mode' nnmex, and votemex (see test_square.m and test_daisy.m for tests of 'descriptor mode' nnmex).
 13 | 
 14 | cores = 2;    % Use more cores for more speed
 15 | 
 16 | disp('start testing descriptor mode');
 17 | 
 18 | if cores==1
 19 |   algo = 'cpu';
 20 | else
 21 |   algo = 'cputiled';
 22 | end
 23 | 
 24 | 
 25 | A=imread('a.png');
 26 | B=imread('b.png');
 27 | B=B(1:end-1,1:end-1,:);
 28 | 
 29 | SA = A; SA(:,:,4:6) = A; SA(:,:,7:9) = A; SA = double(SA);
 30 | SB = B; SB(:,:,4:6) = B; SB(:,:,7:9) = B; SB = double(SB);
 31 | disp('data generated');
 32 | 
 33 | patch_w = 7;
 34 | ann0 = nnmex(SA, SB, algo, [], [], [], [], [], [], cores);   % Warm up
 35 | disp('warm-up finished');
 36 | 
 37 | % Benchmark
 38 | tic;
 39 | nnmex(SA, SB, algo, [], [], [], [], [], [], cores);
 40 | nnmex(SB, SA, algo, [], [], [], [], [], [], cores);
 41 | disp(['NN A <-> B time: ', num2str(toc), ' sec']);
 42 | 
 43 | % Display field
 44 | ann = nnmex(SA, SB, algo, [], [], [], [], [], [], cores);
 45 | bnn = nnmex(SB, SA, algo, [], [], [], [], [], [], cores);
 46 | imshow(ann(:,:,1), []);
 47 | figure
 48 | imshow(sqrt(abs(double(ann(1:end-patch_w,1:end-patch_w,3)))), []);
 49 | figure
 50 | 
 51 | % Display reconstruction
 52 | imshow(votemex(B, ann))       % Coherence
 53 | figure
 54 | imshow(votemex(B, ann, bnn))  % BDS
 55 | 
 56 | % Test 3x3 patches, and clipping
 57 | patch_w = 3;
 58 | ann = nnmex(SA, SB, algo, patch_w, [], [], [], [], [], cores);
 59 | bnn = nnmex(SB, SA, algo, patch_w, [], [], [], [], [], cores);
 60 | % figure
 61 | ann(1,1,1) = -2000;
 62 | ann(2,1,1) = 2000;
 63 | ann(3,1,2) = 2000;
 64 | ann(4,1,2) = -2000;
 65 | bnn(1,1,1) = -2000;
 66 | bnn(2,1,1) = 2000;
 67 | bnn(3,1,2) = 2000;
 68 | bnn(4,1,2) = -2000;
 69 | % imshow(votemex(B, ann, bnn, algo, patch_w));
 70 | 
 71 | % Test initial guess
 72 | tic;
 73 | annp = nnmex(SA, SB, algo, [], 0, [], [], [], [], cores, [], [], ann0);
 74 | disp(['Initial guess mode run for 0 iterations: ', num2str(toc), ' sec']);
 75 | figure
 76 | imshow(votemex(B, annp))       % Coherence
 77 | 
 78 | ann0(1:200,1:200) = 0;
 79 | tic;
 80 | annp = nnmex(SA, SB, algo, [], [], [], [], [], [], cores, [], [], ann0);
 81 | disp(['Initial guess mode run for 5 iterations: ', num2str(toc), ' sec']);
 82 | figure
 83 | imshow(votemex(B, annp))       % Coherence
 84 | 
 85 | 
 86 | close all;
 87 | %% Test for memory leaks
 88 | %A=imresize(A,0.25);
 89 | %B=imresize(B,0.25);
 90 | %B=B(1:end-1,1:end-1,:);
 91 | %ann = nnmex(A, B); bnn = nnmex(B, A);
 92 | %
 93 | %user = memory;
 94 | %disp(['before memory leak test: ', num2str(user.MemUsedMATLAB/1e6), ' MB']);
 95 | %for i=1:100
 96 | %  ann = nnmex(A, B); bnn = nnmex(B, A);
 97 | %end
 98 | %user = memory;
 99 | %disp(['after memory leak test: ', num2str(user.MemUsedMATLAB/1e6), ' MB']);
100 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/test_knn.m:
--------------------------------------------------------------------------------
 1 | 
 2 | cores = 2;
 3 | 
 4 | % kNN without enrichment
 5 | b=imread('b.png');
 6 | c=imread('c.png');
 7 | tic;
 8 | cnn=nnmex(b, b, 'cputiled', 7, 16, [], [], [], [], cores, [], [], [], [], [], 4);
 9 | toc
10 | imshow(cnn(:,:,1,1),'test17.png', []); figure
11 | imshow(cnn(:,:,1,2),'test18.png', []); figure
12 | imshow(cnn(:,:,1,3),'test19.png', []); figure
13 | imshow(cnn(:,:,1,4),'test20.png', []); figure
14 | D = sqrt(double(cnn(:,:,3,:)));
15 | format long;
16 | disp(['Average dist (no enrichment):', num2str(mean(D(:)))]);
17 | 
18 | % kNN with enrichment -- both images must be the same. Enrichment requires the number of NN iterations to be even -- if not it will round down to the next even number.
19 | tic;
20 | cnn=nnmex(b, b, 'enrich', 7, 6, [], [], [], [], cores, [], [], [], [], [], 4);
21 | toc
22 | imshow(cnn(:,:,1,1),'test21.png', []); figure
23 | imshow(cnn(:,:,1,2),'test22.png', []); figure
24 | imshow(cnn(:,:,1,3),'test23.png', []); figure
25 | imshow(cnn(:,:,1,4),'test24.png', [])
26 | D = sqrt(double(cnn(:,:,3,:)));
27 | disp(['Average dist (enrichment):', num2str(mean(D(:)))]);
28 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/test_mex.m:
--------------------------------------------------------------------------------
 1 | %------------------------------------------------------------------------%
 2 | % Copyright 2008-2009 Adobe Systems Inc., for noncommercial use only.
 3 | % Citation:
 4 | %   Connelly Barnes, Eli Shechtman, Adam Finkelstein, and Dan B Goldman.
 5 | %   PatchMatch: A Randomized Correspondence Algorithm for Structural Image
 6 | %   Editing. ACM Transactions on Graphics (Proc. SIGGRAPH), 28(3), 2009
 7 | %   http://www.cs.princeton.edu/gfx/pubs/Barnes_2009_PAR/
 8 | % Main contact: csbarnes@cs.princeton.edu  (Connelly)
 9 | % Version: 1.0, 21-June-2008
10 | %------------------------------------------------------------------------%
11 | 
12 | % Test 'image mode' nnmex, and votemex (see test_square.m and test_daisy.m for tests of 'descriptor mode' nnmex).
13 | 
14 | cores = 2;    % Use more cores for more speed
15 | 
16 | if cores==1
17 |   algo = 'cpu';
18 | else
19 |   algo = 'cputiled';
20 | end
21 | 
22 | A=imread('a.jpg');
23 | B=imread('b.jpg');
24 | B=B(1:end-1,1:end-1,:);
25 | 
26 | patch_w = 3;
27 | ann0 = nnmex(A, B, algo, [], [], [], [], [], [], cores);   % Warm up
28 | 
29 | % Benchmark
30 | tic;
31 | nnmex(A, B, algo, [], [], [], [], [], [], cores);
32 | nnmex(B, A, algo, [], [], [], [], [], [], cores);
33 | disp(['NN A <-> B time: ', num2str(toc), ' sec']);
34 | 
35 | % Display field
36 | ann = nnmex(A, B, algo, [], [], [], [], [], [], cores);
37 | bnn = nnmex(B, A, algo, [], [], [], [], [], [], cores);
38 | imshow(ann(:,:,1), []);
39 | figure
40 | imshow(sqrt(double(ann(1:end-patch_w,1:end-patch_w,3))), []);
41 | figure
42 | 
43 | % Display reconstruction
44 | imshow(votemex(B, ann))       % Coherence
45 | figure
46 | imshow(votemex(B, ann, bnn))  % BDS
47 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/test_rot_scale.m:
--------------------------------------------------------------------------------
 1 | 
 2 | b=imread('b.png');
 3 | c=imread('c.png');
 4 | tic; cnn=nnmex(c,b,'rotscale',7,20); toc
 5 | imshow(cnn(:,:,1),[])
 6 | figure
 7 | imshow(cnn(:,:,4),[])
 8 | 
 9 | % Limiting to only unity scales on this input still works, as the object hasn't changed size too much
10 | tic; cnn=nnmex(c,b,'rotscale',7,20, [], [], [], [], [], [], [], [], [], [], [], 1); toc
11 | figure
12 | imshow(cnn(:,:,1),[])
13 | figure
14 | imshow(cnn(:,:,4),[])
15 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/vecnn.cpp:
--------------------------------------------------------------------------------
  1 | 
  2 | #include "vecnn.h"
  3 | #include "simnn.h"
  4 | 
  5 | template<> int get_maxval() { return INT_MAX; }
  6 | template<> float get_maxval() { return FLT_MAX; }
  7 | template<> double get_maxval() { return DBL_MAX; }
  8 | template<> long long get_maxval() { return LLONG_MAX; }
  9 | 
 10 | VECBITMAP<unsigned char> *bitmap_to_patches(Params *p, BITMAP *a) {
 11 |   //int n = -1, d = -1;
 12 |   //unsigned char *data = im2patches_ub(a, p->patch_w, n, d);
 13 |   //VECBITMAP<unsigned char> *ans = new VECBITMAP<unsigned char>();
 14 |   //ans->w = a->w;
 15 |   //ans->h = a->h;
 16 |   //ans->n = d;
 17 |   //ans->data = data;
 18 |   if (p->vec_len != p->patch_w*p->patch_w*3) { fprintf(stderr, "vec_len (%d) != 3*patch_w**2 (%d)\n", p->vec_len, p->patch_w*p->patch_w*3); exit(1); }
 19 |   VECBITMAP<unsigned char> *ans = new VECBITMAP<unsigned char>(a->w, a->h, p->vec_len);
 20 |   unsigned char *ptr = ans->data;
 21 |   for (int y = 0; y < a->h; y++) {
 22 |     for (int x = 0; x < a->w; x++) {
 23 |       for (int dy = 0; dy < p->patch_w; dy++) {
 24 |         for (int dx = 0; dx < p->patch_w; dx++) {
 25 |           int xp = x+dx, yp = y+dy;
 26 |           if (xp >= a->w) { xp = a->w - 1; }
 27 |           if (yp >= a->h) { yp = a->h - 1; }
 28 |           int c = _getpixel32(a, xp, yp);
 29 |           *ptr++ = getr32(c);
 30 |           *ptr++ = getg32(c);
 31 |           *ptr++ = getb32(c);
 32 |         }
 33 |       }
 34 |     }
 35 |   }
 36 |   int npatches = ptr - ans->data;
 37 |   int n = a->w * a->h * p->vec_len;
 38 |   if (n != npatches) { fprintf(stderr, "n != npatches (%d != %d)\n", n, npatches); exit(1); }
 39 | 
 40 |   return ans;
 41 | }
 42 | 
 43 | BITMAP *vecbitmap_to_bitmap(VECBITMAP<int> *a) {
 44 |   if (a->n != 1) { fprintf(stderr, "vecbitmap n != 1 (%d)\n", a->n); exit(1); }
 45 | 	BITMAP *ans = create_bitmap(a->w, a->h);
 46 |   for (int y = 0; y < a->h; y++) {
 47 |     int *a_row = a->line_n1(y);
 48 |     int *ans_row = (int *) ans->line[y];
 49 |     for (int x = 0; x < a->w; x++) {
 50 |       ans_row[x] = a_row[x];
 51 | 		}
 52 |   }
 53 |   return ans;
 54 | }
 55 | 
 56 | VECBITMAP<int> *bitmap_to_vecbitmap(BITMAP *a) {
 57 |   VECBITMAP<int> *ans = new VECBITMAP<int>(a->w, a->h, 1);
 58 |   for (int y = 0; y < a->h; y++) {
 59 |     int *a_row = (int *) a->line[y];
 60 |     int *ans_row = ans->line_n1(y);
 61 |     for (int x = 0; x < a->w; x++) {
 62 |       ans_row[x] = a_row[x];
 63 |     }
 64 |   }
 65 |   return ans;
 66 | }
 67 | 
 68 | BITMAP *vecwrap_init_nn(int vec_mode, Params *p, BITMAP *a, BITMAP *b, BITMAP *bmask, RegionMasks *region_masks, RegionMasks *amask, BITMAP **ann_sim) {
 69 |   if (vec_mode == VEC_MODE_PATCH) {
 70 |     return init_nn(p, a, b, bmask, region_masks, amask);
 71 |   } 
 72 | 	else if (vec_mode == VEC_MODE_DESC) {
 73 |     VECBITMAP<unsigned char> *av = bitmap_to_patches(p, a);
 74 |     VECBITMAP<unsigned char> *bv = bitmap_to_patches(p, b);
 75 |     BITMAP *ans = vec_init_nn<unsigned char>(p, av, bv, bmask, region_masks, amask);
 76 |     delete av;
 77 |     delete bv;
 78 |     return ans;
 79 |   } 
 80 | 	else if (vec_mode == VEC_MODE_SIM) {
 81 |     if (!ann_sim) { fprintf(stderr, "vecwrap_init_nn: expected argument ann_sim\n"); exit(1); }
 82 |     return sim_init_nn(p, a, b, *ann_sim);
 83 |   } 
 84 | 	else {
 85 |     fprintf(stderr, "vecwrap_init_nn: unknown mode %d\n", vec_mode); exit(1);
 86 |   }
 87 | }
 88 | 
 89 | BITMAP *vecwrap_init_dist(int vec_mode, Params *p, BITMAP *a, BITMAP *b, BITMAP *ann, BITMAP *bmask, RegionMasks *region_masks, RegionMasks *amask, BITMAP *ann_sim) {
 90 |   if (vec_mode == VEC_MODE_PATCH) {
 91 |     return init_dist(p, a, b, ann, bmask, region_masks, amask);
 92 |   } 
 93 | 	else if (vec_mode == VEC_MODE_DESC) {
 94 |     VECBITMAP<unsigned char> *av = bitmap_to_patches(p, a);
 95 |     VECBITMAP<unsigned char> *bv = bitmap_to_patches(p, b);
 96 | 
 97 |     VECBITMAP<int> *ans = vec_init_dist<unsigned char, int>(p, av, bv, ann, bmask, region_masks, amask);
 98 | 
 99 |     delete av;
100 |     delete bv;
101 |     BITMAP *ansd = vecbitmap_to_bitmap(ans);
102 |     delete ans;
103 |     return ansd;
104 |   } 
105 | 	else if (vec_mode == VEC_MODE_SIM) {
106 |     if (!ann_sim) { fprintf(stderr, "vecwrap_init_dist: expected argument ann_sim\n"); exit(1); }
107 |     return sim_init_dist(p, a, b, ann, ann_sim);
108 |   } 
109 | 	else {
110 |     fprintf(stderr, "vecwrap_init_dist: unknown mode %d\n", vec_mode); exit(1);
111 |   }
112 | }
113 | 
114 | void vecwrap_nn(int vec_mode, Params *p, BITMAP *a, BITMAP *b,
115 |         BITMAP *ann, BITMAP *annd,
116 |         RegionMasks *amask, BITMAP *bmask,
117 |         int level, int em_iter, RecomposeParams *rp, int offset_iter, int update_type, int cache_b,
118 |         RegionMasks *region_masks, int tiles, BITMAP *ann_sim) 
119 | {
120 |   if (vec_mode == VEC_MODE_PATCH) {
121 |     return nn(p, a, b, ann, annd, amask, bmask, level, em_iter, rp, offset_iter, update_type, cache_b, region_masks, tiles);
122 |   } 
123 |   else if (vec_mode == VEC_MODE_DESC) {
124 |     VECBITMAP<unsigned char> *av = bitmap_to_patches(p, a);
125 |     VECBITMAP<unsigned char> *bv = bitmap_to_patches(p, b);
126 |     VECBITMAP<int> *anndv = bitmap_to_vecbitmap(annd);
127 | 
128 |     vec_nn<unsigned char, int>(p, av, bv, ann, anndv, amask, bmask, level, em_iter, rp, offset_iter, update_type, cache_b, region_masks, tiles);
129 | 
130 |     BITMAP *anndp = vecbitmap_to_bitmap(anndv);
131 |     if (anndp->w != annd->w || anndp->h != annd->h) { fprintf(stderr, "Sizes differ in vecwrap_nn: %dx%d, %dx%d\n", anndp->w, anndp->h, annd->w, annd->h); exit(1); }
132 |     blit(anndp, annd, 0, 0, 0, 0, anndp->w, anndp->h);
133 | 
134 |     delete av;
135 |     delete bv;
136 |     delete anndv;
137 |     destroy_bitmap(anndp);
138 |   } 
139 |   else if (vec_mode == VEC_MODE_SIM) {
140 |     if (!ann_sim) { fprintf(stderr, "vecwrap_nn: expected argument ann_sim\n"); exit(1); }
141 |     return sim_nn(p, a, b, ann, ann_sim, annd, amask, bmask, level, em_iter, rp, offset_iter, update_type, cache_b, region_masks, tiles);
142 |   } 
143 |   else {
144 |     fprintf(stderr, "vecwrap_nn: unknown mode %d\n", vec_mode); exit(1);
145 |   }
146 | }
147 | 
148 | BITMAP *vecwrap_vote(int vec_mode, Params *p, BITMAP *b,
149 |          BITMAP *ann, BITMAP *ann_sim, BITMAP *bnn,
150 |          BITMAP *bmask, BITMAP *bweight,
151 |          double coherence_weight, double complete_weight,
152 |          RegionMasks *amask, BITMAP *aweight, BITMAP *ainit, RegionMasks *region_masks, BITMAP *aconstraint, int mask_self_only) 
153 | {
154 |   if (vec_mode == VEC_MODE_PATCH || vec_mode == VEC_MODE_DESC) {
155 |     return vote(p, b, ann, bnn, bmask, bweight, coherence_weight, complete_weight, amask, aweight, ainit, region_masks, aconstraint, mask_self_only);
156 |   }
157 | 	else if (vec_mode == VEC_MODE_SIM) {
158 |     if (!ann_sim) { fprintf(stderr, "vecwrap_vote: expected argument ann_sim\n"); exit(1); }
159 |     return sim_vote(p, b, ann, ann_sim, bnn, NULL, bmask, bweight, coherence_weight, complete_weight, amask, aweight, ainit, region_masks, aconstraint, mask_self_only);
160 |   } 
161 | 	else {
162 |     fprintf(stderr, "vecwrap_vote: unknown mode %d\n", vec_mode); exit(1);
163 |   }
164 | }
165 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/vecpatch.h:
--------------------------------------------------------------------------------
  1 | 
  2 | /* Patch distance templates for vector input. */
  3 | 
  4 | #ifndef _vecpatch_h
  5 | #define _vecpatch_h
  6 | 
  7 | #include "vecnn.h"
  8 | 
  9 | template<class T, class ACCUM, int IS_WINDOW>
 10 | ACCUM vec_fast_patch_dist(T *apatch, T *bpatch, ACCUM maxval, Params *p) {
 11 |   ACCUM ans = 0;
 12 |   for (int i = 0; i < p->vec_len; i++) {
 13 |     ACCUM d = ((ACCUM) apatch[i])-((ACCUM) bpatch[i]);
 14 |     ans += d*d;
 15 |     if (ans > maxval) { return ans; }
 16 |   }
 17 |   return ans;
 18 | }
 19 | 
 20 | template<class T, class ACCUM, int IS_MASK, int IS_WINDOW>
 21 | void vec_attempt_n(ACCUM &err, int &xbest, int &ybest, T *apatch, VECBITMAP<T> *b, int bx, int by, BITMAP *bmask, RegionMasks *region_masks, int src_mask, Params *p) {
 22 |   if ((bx != xbest || by != ybest) &&
 23 |       (unsigned) bx < (unsigned) (b->w) &&
 24 |       (unsigned) by < (unsigned) (b->h)) 
 25 | 	{
 26 |     if (IS_MASK && region_masks && src_mask != ((int *) region_masks->bmp->line[by])[bx]) { return; }
 27 |     if (IS_MASK && bmask && ((int *) bmask->line[by])[bx]) { return; }
 28 |     ACCUM current = vec_fast_patch_dist<T, ACCUM, IS_WINDOW>(apatch, b->get(bx, by), err, p);
 29 |     if (current < err) {
 30 |       err = current;
 31 |       xbest = bx;
 32 |       ybest = by;
 33 |     }
 34 |   }
 35 | }
 36 | 
 37 | template<class T, class ACCUM, int IS_WINDOW>
 38 | ACCUM vec_fast_patch_nobranch(T *apatch, T *bpatch, Params *p) {
 39 |   ACCUM ans = 0;
 40 |   for (int i = 0; i < p->vec_len; i++) {
 41 |     ACCUM d = ((ACCUM) apatch[i])-((ACCUM) bpatch[i]);
 42 |     ans += d*d;
 43 |   }
 44 |   return ans;
 45 | }
 46 | 
 47 | template<class T, class ACCUM, int IS_WINDOW, int HAS_MASKS>
 48 | ACCUM vec_patch_dist_ab(Params *p, VECBITMAP<T> *a, int ax, int ay, VECBITMAP<T> *b, int bx, int by, ACCUM maxval, RegionMasks *region_masks) {
 49 |   if (HAS_MASKS && region_masks && ((int *) region_masks->bmp->line[ay])[ax] != ((int *) region_masks->bmp->line[by])[bx]) 
 50 | 		return get_maxval<ACCUM>();
 51 |   return vec_fast_patch_nobranch<T, ACCUM, IS_WINDOW>(a->get(ax, ay), b->get(bx, by), p);
 52 | }
 53 | 
 54 | 
 55 | // -----------------------------
 56 | // XC version
 57 | // -----------------------------
 58 | 
 59 | template<class T, class ACCUM, int IS_WINDOW, int PATCH_W>
 60 | ACCUM XCvec_fast_patch_nobranch(T *adata[PATCH_W][PATCH_W], VECBITMAP<T> *b, int bx, int by, Params *p) 
 61 | {
 62 |   ACCUM ans = 0;
 63 | 
 64 | 	// aggregate a patch of vectors for b, assume we have trimed patches to possible choices
 65 | 	T *bdata[PATCH_W][PATCH_W]; 
 66 | 	for (int dy = 0; dy < PATCH_W; dy++) { 
 67 |     for (int dx = 0; dx < PATCH_W; dx++) {
 68 | 			bdata[dy][dx] = b->get(bx+dx, by+dy);
 69 |     }
 70 |   } 
 71 | 
 72 | 	// patch distance
 73 | 	for (int dy = 0; dy < PATCH_W; dy++) {
 74 | 		for (int dx = 0; dx < PATCH_W; dx++) {
 75 | 			T *apatch = adata[dy][dx];
 76 | 			T *bpatch = bdata[dy][dx];
 77 | 			for(int i = 0; i < p->vec_len; i ++) {
 78 | 				ACCUM d = ((ACCUM) apatch[i])-((ACCUM) bpatch[i]);
 79 | 				ans += d*d;
 80 | 			}
 81 | 		}
 82 | 	}
 83 | 	
 84 | 	return ans;
 85 | }
 86 | 
 87 | 
 88 | template<class T, class ACCUM, int IS_WINDOW, int PATCH_W>
 89 | ACCUM XCvec_fast_patch_dist(T *adata[PATCH_W][PATCH_W], VECBITMAP<T> *b, int bx, int by, ACCUM maxval, Params *p) {
 90 |   ACCUM ans = 0;
 91 | 
 92 | 	// aggregate a patch of vectors for b, assume we have trimed patches to possible choices
 93 | 	T *bdata[PATCH_W][PATCH_W]; 
 94 | 	for (int dy = 0; dy < PATCH_W; dy++) { 
 95 |     for (int dx = 0; dx < PATCH_W; dx++) {
 96 | 			bdata[dy][dx] = b->get(bx+dx, by+dy);
 97 |     }
 98 |   } 
 99 | 
100 | 	// patch distance
101 | 	for (int dy = 0; dy < PATCH_W; dy++) {
102 | 		for (int dx = 0; dx < PATCH_W; dx++) {
103 | 			T *apatch = adata[dy][dx];
104 | 			T *bpatch = bdata[dy][dx];
105 | 			for(int i = 0; i < p->vec_len; i ++) {
106 | 				ACCUM d = ((ACCUM) apatch[i])-((ACCUM) bpatch[i]);
107 | 				ans += d*d;
108 | 				if (ans > maxval) { return ans; }
109 | 			}
110 | 		}
111 | 	}
112 | 	
113 | 	return ans;
114 | }
115 | 
116 | 
117 | template<class T, class ACCUM, int IS_MASK, int IS_WINDOW, int PATCH_W>
118 | void XCvec_attempt_n(ACCUM &err, int &xbest, int &ybest, T *adata[PATCH_W][PATCH_W], VECBITMAP<T> *b, int bx, int by, BITMAP *bmask, RegionMasks *region_masks, int src_mask, Params *p) {
119 |   if ((bx != xbest || by != ybest) &&
120 |       (unsigned) bx < (unsigned) (b->w-PATCH_W+1) &&
121 |       (unsigned) by < (unsigned) (b->h-PATCH_W+1)) 
122 | 	{
123 |     if (IS_MASK && region_masks && src_mask != ((int *) region_masks->bmp->line[by])[bx]) { return; }
124 |     if (IS_MASK && bmask && ((int *) bmask->line[by])[bx]) { return; }
125 |     ACCUM current = XCvec_fast_patch_dist<T, ACCUM, IS_WINDOW, PATCH_W>(adata, b, bx, by, err, p);
126 |     if (current < err) {
127 |       err = current;
128 |       xbest = bx;
129 |       ybest = by;
130 |     }
131 |   }
132 | }
133 | 
134 | 
135 | template<class T, class ACCUM, int IS_WINDOW, int HAS_MASKS, int PATCH_W>
136 | ACCUM XCvec_patch_dist_ab(Params *p, VECBITMAP<T> *a, int ax, int ay, VECBITMAP<T> *b, int bx, int by, ACCUM maxval, RegionMasks *region_masks) {
137 |   if (HAS_MASKS && region_masks && ((int *) region_masks->bmp->line[ay])[ax] != ((int *) region_masks->bmp->line[by])[bx]) 
138 | 		return get_maxval<ACCUM>();
139 | 
140 | 	// aggregate a patch of vectors for a, assume we have trimed patches to possible choices
141 | 	T *adata[PATCH_W][PATCH_W]; 
142 | 	for (int dy = 0; dy < PATCH_W; dy++) { 
143 |     for (int dx = 0; dx < PATCH_W; dx++) {
144 | 			adata[dy][dx] = a->get(ax+dx, ay+dy);
145 |     }
146 |   } 
147 | 
148 |   return XCvec_fast_patch_nobranch<T, ACCUM, IS_WINDOW, PATCH_W>(adata, b, bx, by, p);
149 | }
150 | 
151 | 
152 | #endif
153 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/votemex.cpp:
--------------------------------------------------------------------------------
 1 | 
 2 | // MATLAB interface, for vote().
 3 | 
 4 | #include "allegro_emu.h"
 5 | #include "mex.h"
 6 | #include "nn.h"
 7 | //#include "matrix.h"
 8 | #include "mexutil.h"
 9 | 
10 | void mexFunction(int nout, mxArray *pout[], int nin, const mxArray *pin[]) {
11 |   if (nin < 2) { mexErrMsgTxt("votemex called with < 2 input arguments"); }
12 |   const mxArray *B = pin[0], *Ann = pin[1], *Bnn = NULL;
13 | 
14 |   BITMAP *b = convert_bitmap(B);
15 | 
16 |   Params *p = new Params();
17 |   // [bnn=[]], [algo='cpu'], [patch_w=7], [bmask=[]], [bweight=[]], [coherence_weight=1], [complete_weight=1], [amask=[]], [aweight=[]]
18 |   BITMAP *bmask = NULL, *bweight = NULL, *amask = NULL, *aweight = NULL, *ainit = NULL;
19 |   double coherence_weight = 1, complete_weight = 1;
20 |   int i = 2;
21 |   if (nin > i && !mxIsEmpty(pin[i])) { Bnn = pin[i]; } i++;
22 |   if (nin > i && !mxIsEmpty(pin[i])) {
23 |     if			(mxStringEquals(pin[i], "cpu")) { p->algo = ALGO_CPU; }
24 |     else if (mxStringEquals(pin[i], "gpucpu")) { p->algo = ALGO_GPUCPU; }
25 |     else if (mxStringEquals(pin[i], "cputiled")) { p->algo = ALGO_CPUTILED; }
26 |     else { mexErrMsgTxt("Unknown algorithm"); }
27 |   } i++;
28 |   if (nin > i && !mxIsEmpty(pin[i])) { p->patch_w = int(mxGetScalar(pin[i])); } i++;
29 |   if (nin > i && !mxIsEmpty(pin[i])) { bmask = convert_bitmap(pin[i]); } i++;
30 |   if (nin > i && !mxIsEmpty(pin[i])) { bweight = convert_bitmapf(pin[i]); } i++;
31 |   if (nin > i && !mxIsEmpty(pin[i])) { coherence_weight = mxGetScalar(pin[i]); } i++;
32 |   if (nin > i && !mxIsEmpty(pin[i])) { complete_weight = mxGetScalar(pin[i]); } i++;
33 |   if (nin > i && !mxIsEmpty(pin[i])) { amask = convert_bitmap(pin[i]); } i++;
34 |   if (nin > i && !mxIsEmpty(pin[i])) { aweight = convert_bitmapf(pin[i]); } i++;
35 |   if (nin > i && !mxIsEmpty(pin[i])) { ainit = convert_bitmap(pin[i]); } i++;
36 | 
37 |   int aclip = 0, bclip = 0;
38 |   BITMAP *ann = convert_field(p, Ann, b->w, b->h, aclip);
39 |   BITMAP *bnn = Bnn ? convert_field(p, Bnn, ann->w, ann->h, bclip): NULL;
40 | 
41 |   int nclip = aclip + bclip;
42 |   //if (nclip) printf("Warning: clipped %d votes (%d a -> b, %d b -> a)\n", nclip, aclip, bclip);
43 | 
44 |   RegionMasks *amaskm = amask ? new RegionMasks(p, amask): NULL;
45 |   //BITMAP *a = vote(p, b, ann, bnn, bmask, bweight, coherence_weight, complete_weight, amaskm, aweight, ainit);
46 |   // David Jacobs -- Added mask_self_only as true for multiple.
47 |   BITMAP *a = vote(p, b, ann, bnn, bmask, bweight, coherence_weight, complete_weight, amaskm, aweight, ainit, NULL, NULL, 1);
48 | 	
49 |   destroy_region_masks(amaskm);
50 | 
51 | 	if(nout >= 1) {
52 | 		mxArray *ans = bitmap_to_array(a);
53 | 		pout[0] = ans;
54 |   } 
55 | 
56 |   delete p;
57 |   destroy_bitmap(a);
58 |   destroy_bitmap(ainit);
59 |   destroy_bitmap(b);
60 |   destroy_bitmap(ann);
61 |   destroy_bitmap(bnn);
62 |   destroy_bitmap(bmask);
63 |   destroy_bitmap(bweight);
64 | //  destroy_bitmap(amask);
65 |   destroy_bitmap(aweight);
66 | }
67 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/votemex.m:
--------------------------------------------------------------------------------
 1 | %function A = votemex(B, ann, [bnn=[]], [algo='cpu'], [patch_w=7],
 2 | %[bmask=[]], [bweight=[]], [coherence_weight=1], [complete_weight=1],
 3 | %[amask=[]], [aweight=[]]), [A0=[]]
 4 | %
 5 | %
 6 | %Input image B is hxwx3, floats in [0, 1] or uint8.
 7 | %Input fields are:
 8 | % ann = nnmex(A, B)
 9 | % bnn = nnmex(B, A)
10 | %If bnn unspecified, uses coherence only.
11 | %
12 | %Options are:
13 | %algo             - One of 'cpu', 'cputiled'
14 | %patch_w          - Width (and height) of patch, currently support sizes up to 32
15 | %bmask            - B mask image, votes made only where mask is zero
16 | %                   (affects both 'coherence' and 'completeness'
17 | %bweight          - B weight image, weights are 32 bit floats, and
18 | %                   correspond to the *center* of the patch
19 | %coherence_weight - Weight multiplier for coherence
20 | %complete_weight  - Weight multiplier for completeness
21 | %amask            - A mask image, votes made only where mask is zero
22 | %                   (affects only 'coherence')
23 | %aweight          - A weight image, if not given uses inverse mapping
24 | %                   and B weight image. Corresponds to the *center* of the
25 | %                   patch.
26 | %A0               - Initial guess for A. It is used as default in regions
27 | %                   with no votes - outside the output mask 'amask' and
28 | %                   with no votes from the input.
29 | %
30 | %NOTE: all NN fields and masks correspond to the upper-left corner of the
31 | %patches, and the field indeces are in C coordinates (start with [0,0]),
32 | %wheras the weight maps correspond to the *center* of the patch.
33 | %
34 | %
35 | %------------------------------------------------------------------------%
36 | % Copyright 2008-2009 Adobe Systems Inc., for noncommercial use only.
37 | % Citation:
38 | %   Connelly Barnes, Eli Shechtman, Adam Finkelstein, and Dan B Goldman.
39 | %   PatchMatch: A Randomized Correspondence Algorithm for Structural Image
40 | %   Editing. ACM Transactions on Graphics (Proc. SIGGRAPH), 28(3), 2009
41 | %   http://www.cs.princeton.edu/gfx/pubs/Barnes_2009_PAR/
42 | % Main contact: csbarnes@cs.princeton.edu  (Connelly)
43 | % Version: 1.0, 21-June-2008
44 | %------------------------------------------------------------------------%
45 | 
46 | 


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/votemex.mexa64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/patchmatch-2.0/votemex.mexa64


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/votemex.mexw64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/3rdparty/patchmatch-2.0/votemex.mexw64


--------------------------------------------------------------------------------
/3rdparty/patchmatch-2.0/writeim.m:
--------------------------------------------------------------------------------
1 | function out = writeim(A, filename)
2 | 
3 | a = min(A(:));
4 | b = max(A(:));
5 | A = uint8((A-a)*(255/(b-a)));
6 | imwrite(A, filename);
7 | 


--------------------------------------------------------------------------------
/README2.md:
--------------------------------------------------------------------------------
  1 | 
  2 | ## Disclaimer 
  3 | **We don't own the copyright of some images below. Use with caution.**
  4 | 
  5 | ## Examples
  6 | Here are some results from our algorithm (from left to right are original painting, naive composite and our output):
  7 | <p align='center'>
  8 |   <img src='data/0_target.jpg' width='290'/>
  9 |   <img src='data/0_naive.jpg' width='290'/>
 10 |   <img src='results/0_final_res2.png' width='290'/>
 11 | </p>
 12 | <p align='center'>
 13 |   <img src='data/1_target.jpg' width='290'/>
 14 |   <img src='data/1_naive.jpg' width='290'/>
 15 |   <img src='results/1_final_res2.png' width='290'/>
 16 | </p>
 17 | <p align='center'>
 18 |   <img src='data/2_target.jpg' width='290'/>
 19 |   <img src='data/2_naive.jpg' width='290'/>
 20 |   <img src='results/2_final_res2.png' width='290'/>
 21 | </p>
 22 | <p align='center'>
 23 |   <img src='data/3_target.jpg' width='290'/>
 24 |   <img src='data/3_naive.jpg' width='290'/>
 25 |   <img src='results/3_final_res2.png' width='290'/>
 26 | </p>
 27 | <p align='center'>
 28 |   <img src='data/4_target.jpg' width='290'/>
 29 |   <img src='data/4_naive.jpg' width='290'/>
 30 |   <img src='results/4_final_res2.png' width='290'/>
 31 | </p>
 32 | <p align='center'>
 33 |   <img src='data/5_target.jpg' width='290'/>
 34 |   <img src='data/5_naive.jpg' width='290'/>
 35 |   <img src='results/5_final_res2.png' width='290'/>
 36 | </p>
 37 | <p align='center'>
 38 |   <img src='data/6_target.jpg' width='290'/>
 39 |   <img src='data/6_naive.jpg' width='290'/>
 40 |   <img src='results/6_final_res2.png' width='290'/>
 41 | </p>
 42 |  
 43 | <p align='center'>
 44 |   <img src='data/7_target.jpg' width='290'/>
 45 |   <img src='data/7_naive.jpg' width='290'/>
 46 |   <img src='results/7_final_res2.png' width='290'/>
 47 | </p>
 48 |  
 49 | <p align='center'>
 50 |   <img src='results/7_target.jpg' width='290'/>
 51 |   <img src='results/7_naive_popeye.png' width='290'/>
 52 |   <img src='results/7_result_popeye.jpg' width='290'/>
 53 | </p>
 54 | 
 55 |  
 56 | <p align='center'>
 57 |   <img src='data/8_target.jpg' width='290'/>
 58 |   <img src='data/8_naive.jpg' width='290'/>
 59 |   <img src='results/8_final_res.png' width='290'/>
 60 | </p>
 61 | <p align='center'>
 62 |   <img src='data/8_target.jpg' width='290'/>
 63 |   <img src='results/8_naive_balloon.jpg' width='290'/>
 64 |   <img src='results/8_result_balloon.jpg' width='290'/>
 65 | </p>
 66 |  
 67 | 
 68 | <p align='center'>
 69 |   <img src='data/8_target.jpg' width='290'/>
 70 |   <img src='results/8_naive_aircraft.png' width='290'/>
 71 |   <img src='results/8_result_aircraft.png' width='290'/>
 72 | </p>
 73 | 
 74 |  
 75 | <p align='center'>
 76 |   <img src='data/9_target.jpg' width='290'/>
 77 |   <img src='data/9_naive.jpg' width='290'/>
 78 |   <img src='results/9_final_res2.png' width='290'/>
 79 | </p>
 80 |  
 81 | <p align='center'>
 82 |   <img src='data/9_target.jpg' width='290'/>
 83 |   <img src='results/9_naive_dragon.png' width='290'/>
 84 |   <img src='results/9_result_dragon.jpg' width='290'/>
 85 | </p>
 86 | 
 87 | <p align='center'>
 88 |   <img src='data/10_target.jpg' width='290'/>
 89 |   <img src='data/10_naive.jpg' width='290'/>
 90 |   <img src='results/10_final_res2.png' width='290'/>
 91 | </p>
 92 | <p align='center'>
 93 |   <img src='data/11_target.jpg' width='290'/>
 94 |   <img src='data/11_naive.jpg' width='290'/>
 95 |   <img src='results/11_final_res2.png' width='290'/>
 96 | </p>
 97 | <p align='center'>
 98 |   <img src='data/12_target.jpg' width='290'/>
 99 |   <img src='data/12_naive.jpg' width='290'/>
100 |   <img src='results/12_final_res2.png' width='290'/>
101 | </p>
102 | <p align='center'>
103 |   <img src='data/13_target.jpg' width='290'/>
104 |   <img src='data/13_naive.jpg' width='290'/>
105 |   <img src='results/13_final_res2.png' width='290'/>
106 | </p>
107 | <p align='center'>
108 |   <img src='data/14_target.jpg' width='290'/>
109 |   <img src='data/14_naive.jpg' width='290'/>
110 |   <img src='results/14_final_res2.png' width='290'/>
111 | </p>
112 | <p align='center'>
113 |   <img src='data/15_target.jpg' width='290'/>
114 |   <img src='data/15_naive.jpg' width='290'/>
115 |   <img src='results/15_final_res2.png' width='290'/>
116 | </p>
117 | <p align='center'>
118 |   <img src='data/16_target.jpg' width='290'/>
119 |   <img src='data/16_naive.jpg' width='290'/>
120 |   <img src='results/16_final_res2.png' width='290'/>
121 | </p>
122 | 
123 |  
124 | <p align='center'>
125 |   <img src='data/17_target.jpg' width='290'/>
126 |   <img src='data/17_naive.jpg' width='290'/>
127 |   <img src='results/17_final_res2.png' width='290'/>
128 | </p>
129 |  
130 | 
131 | 
132 | <p align='center'>
133 |   <img src='data/17_target.jpg' width='290'/>
134 |   <img src='results/17_naive_sherlock.jpg' width='290'/>
135 |   <img src='results/17_result_sherlock.jpg' width='290'/>
136 | </p>
137 | <p align='center'>
138 |   <img src='data/18_target.jpg' width='290'/>
139 |   <img src='data/18_naive.jpg' width='290'/>
140 |   <img src='results/18_final_res2.png' width='290'/>
141 | </p>
142 | <p align='center'>
143 |   <img src='data/19_target.jpg' width='290'/>
144 |   <img src='data/19_naive.jpg' width='290'/>
145 |   <img src='results/19_final_res2.png' width='290'/>
146 | </p>
147 | <p align='center'>
148 |   <img src='data/20_target.jpg' width='290'/>
149 |   <img src='data/20_naive.jpg' width='290'/>
150 |   <img src='results/20_final_res2.png' width='290'/>
151 | </p>
152 | <p align='center'>
153 |   <img src='data/21_target.jpg' width='290'/>
154 |   <img src='data/21_naive.jpg' width='290'/>
155 |   <img src='results/21_final_res2.png' width='290'/>
156 | </p>
157 | <p align='center'>
158 |   <img src='data/22_target.jpg' width='290'/>
159 |   <img src='data/22_naive.jpg' width='290'/>
160 |   <img src='results/22_final_res2.png' width='290'/>
161 | </p>
162 | <p align='center'>
163 |   <img src='data/23_target.jpg' width='290'/>
164 |   <img src='data/23_naive.jpg' width='290'/>
165 |   <img src='results/23_final_res2.png' width='290'/>
166 | </p>
167 | <p align='center'>
168 |   <img src='data/24_target.jpg' width='290'/>
169 |   <img src='data/24_naive.jpg' width='290'/>
170 |   <img src='results/24_final_res2.png' width='290'/>
171 | </p>
172 | <p align='center'>
173 |   <img src='data/25_target.jpg' width='290'/>
174 |   <img src='data/25_naive.jpg' width='290'/>
175 |   <img src='results/25_final_res2.png' width='290'/>
176 | </p>
177 | <p align='center'>
178 |   <img src='data/26_target.jpg' width='290'/>
179 |   <img src='data/26_naive.jpg' width='290'/>
180 |   <img src='results/26_final_res2.png' width='290'/>
181 | </p>
182 | <p align='center'>
183 |   <img src='data/27_target.jpg' width='290'/>
184 |   <img src='data/27_naive.jpg' width='290'/>
185 |   <img src='results/27_final_res2.png' width='290'/>
186 | </p>
187 | 
188 |  
189 | <p align='center'>
190 |   <img src='data/28_target.jpg' width='290'/>
191 |   <img src='data/28_naive.jpg' width='290'/>
192 |   <img src='results/28_final_res2.png' width='290'/>
193 | </p>
194 |  
195 | <p align='center'>
196 |   <img src='data/28_target.jpg' width='290'/>
197 |   <img src='results/28_naive_cow.png' width='290'/>
198 |   <img src='results/28_result_cow.jpg' width='290'/>
199 | </p>
200 | 
201 | <p align='center'>
202 |   <img src='data/29_target.jpg' width='290'/>
203 |   <img src='data/29_naive.jpg' width='290'/>
204 |   <img src='results/29_final_res2.png' width='290'/>
205 | </p>
206 | <p align='center'>
207 |   <img src='data/30_target.jpg' width='290'/>
208 |   <img src='data/30_naive.jpg' width='290'/>
209 |   <img src='results/30_final_res2.png' width='290'/>
210 | </p>
211 | <p align='center'>
212 |   <img src='data/31_target.jpg' width='290'/>
213 |   <img src='data/31_naive.jpg' width='290'/>
214 |   <img src='results/31_final_res2.png' width='290'/>
215 | </p>
216 | <p align='center'>
217 |   <img src='data/32_target.jpg' width='290'/>
218 |   <img src='data/32_naive.jpg' width='290'/>
219 |   <img src='results/32_final_res2.png' width='290'/>
220 | </p>
221 | 
222 | <p align='center'>
223 |   <img src='data/35_target.jpg' width='290'/>
224 |   <img src='results/35_naive.jpg' width='290'/>
225 |   <img src='results/35_result.png' width='290'/>
226 | </p>
227 | 
228 | 
229 | <p align='center'>
230 |   <img src='data/33_target.jpg' width='290'/>
231 |   <img src='results/33_naive_buddha.png' width='290'/>
232 |   <img src='results/33_result_buddha.jpg' width='290'/>
233 | </p>
234 | 
235 | <p align='center'>
236 |   <img src='data/33_target.jpg' width='290'/>
237 |   <img src='data/33_naive.jpg' width='290'/>
238 |   <img src='results/33_final_res2.png' width='290'/>
239 | </p>
240 | 
241 | <p align='center'>
242 |   <img src='data/34_target.jpg' width='290'/>
243 |   <img src='data/34_naive.jpg' width='290'/>
244 |   <img src='results/34_final_res2.png' width='290'/>
245 | </p>
246 | 


--------------------------------------------------------------------------------
/data/0_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/0_c_mask.jpg


--------------------------------------------------------------------------------
/data/0_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/0_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/0_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/0_naive.jpg


--------------------------------------------------------------------------------
/data/0_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/0_target.jpg


--------------------------------------------------------------------------------
/data/10_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/10_c_mask.jpg


--------------------------------------------------------------------------------
/data/10_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/10_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/10_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/10_naive.jpg


--------------------------------------------------------------------------------
/data/10_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/10_target.jpg


--------------------------------------------------------------------------------
/data/11_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/11_c_mask.jpg


--------------------------------------------------------------------------------
/data/11_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/11_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/11_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/11_naive.jpg


--------------------------------------------------------------------------------
/data/11_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/11_target.jpg


--------------------------------------------------------------------------------
/data/12_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/12_c_mask.jpg


--------------------------------------------------------------------------------
/data/12_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/12_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/12_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/12_naive.jpg


--------------------------------------------------------------------------------
/data/12_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/12_target.jpg


--------------------------------------------------------------------------------
/data/13_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/13_c_mask.jpg


--------------------------------------------------------------------------------
/data/13_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/13_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/13_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/13_naive.jpg


--------------------------------------------------------------------------------
/data/13_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/13_target.jpg


--------------------------------------------------------------------------------
/data/14_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/14_c_mask.jpg


--------------------------------------------------------------------------------
/data/14_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/14_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/14_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/14_naive.jpg


--------------------------------------------------------------------------------
/data/14_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/14_target.jpg


--------------------------------------------------------------------------------
/data/15_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/15_c_mask.jpg


--------------------------------------------------------------------------------
/data/15_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/15_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/15_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/15_naive.jpg


--------------------------------------------------------------------------------
/data/15_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/15_target.jpg


--------------------------------------------------------------------------------
/data/16_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/16_c_mask.jpg


--------------------------------------------------------------------------------
/data/16_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/16_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/16_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/16_naive.jpg


--------------------------------------------------------------------------------
/data/16_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/16_target.jpg


--------------------------------------------------------------------------------
/data/17_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/17_c_mask.jpg


--------------------------------------------------------------------------------
/data/17_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/17_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/17_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/17_naive.jpg


--------------------------------------------------------------------------------
/data/17_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/17_target.jpg


--------------------------------------------------------------------------------
/data/18_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/18_c_mask.jpg


--------------------------------------------------------------------------------
/data/18_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/18_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/18_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/18_naive.jpg


--------------------------------------------------------------------------------
/data/18_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/18_target.jpg


--------------------------------------------------------------------------------
/data/19_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/19_c_mask.jpg


--------------------------------------------------------------------------------
/data/19_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/19_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/19_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/19_naive.jpg


--------------------------------------------------------------------------------
/data/19_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/19_target.jpg


--------------------------------------------------------------------------------
/data/1_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/1_c_mask.jpg


--------------------------------------------------------------------------------
/data/1_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/1_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/1_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/1_naive.jpg


--------------------------------------------------------------------------------
/data/1_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/1_target.jpg


--------------------------------------------------------------------------------
/data/20_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/20_c_mask.jpg


--------------------------------------------------------------------------------
/data/20_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/20_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/20_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/20_naive.jpg


--------------------------------------------------------------------------------
/data/20_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/20_target.jpg


--------------------------------------------------------------------------------
/data/21_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/21_c_mask.jpg


--------------------------------------------------------------------------------
/data/21_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/21_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/21_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/21_naive.jpg


--------------------------------------------------------------------------------
/data/21_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/21_target.jpg


--------------------------------------------------------------------------------
/data/22_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/22_c_mask.jpg


--------------------------------------------------------------------------------
/data/22_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/22_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/22_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/22_naive.jpg


--------------------------------------------------------------------------------
/data/22_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/22_target.jpg


--------------------------------------------------------------------------------
/data/23_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/23_c_mask.jpg


--------------------------------------------------------------------------------
/data/23_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/23_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/23_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/23_naive.jpg


--------------------------------------------------------------------------------
/data/23_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/23_target.jpg


--------------------------------------------------------------------------------
/data/24_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/24_c_mask.jpg


--------------------------------------------------------------------------------
/data/24_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/24_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/24_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/24_naive.jpg


--------------------------------------------------------------------------------
/data/24_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/24_target.jpg


--------------------------------------------------------------------------------
/data/25_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/25_c_mask.jpg


--------------------------------------------------------------------------------
/data/25_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/25_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/25_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/25_naive.jpg


--------------------------------------------------------------------------------
/data/25_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/25_target.jpg


--------------------------------------------------------------------------------
/data/26_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/26_c_mask.jpg


--------------------------------------------------------------------------------
/data/26_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/26_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/26_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/26_naive.jpg


--------------------------------------------------------------------------------
/data/26_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/26_target.jpg


--------------------------------------------------------------------------------
/data/27_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/27_c_mask.jpg


--------------------------------------------------------------------------------
/data/27_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/27_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/27_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/27_naive.jpg


--------------------------------------------------------------------------------
/data/27_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/27_target.jpg


--------------------------------------------------------------------------------
/data/28_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/28_c_mask.jpg


--------------------------------------------------------------------------------
/data/28_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/28_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/28_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/28_naive.jpg


--------------------------------------------------------------------------------
/data/28_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/28_target.jpg


--------------------------------------------------------------------------------
/data/29_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/29_c_mask.jpg


--------------------------------------------------------------------------------
/data/29_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/29_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/29_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/29_naive.jpg


--------------------------------------------------------------------------------
/data/29_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/29_target.jpg


--------------------------------------------------------------------------------
/data/2_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/2_c_mask.jpg


--------------------------------------------------------------------------------
/data/2_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/2_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/2_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/2_naive.jpg


--------------------------------------------------------------------------------
/data/2_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/2_target.jpg


--------------------------------------------------------------------------------
/data/30_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/30_c_mask.jpg


--------------------------------------------------------------------------------
/data/30_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/30_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/30_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/30_naive.jpg


--------------------------------------------------------------------------------
/data/30_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/30_target.jpg


--------------------------------------------------------------------------------
/data/31_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/31_c_mask.jpg


--------------------------------------------------------------------------------
/data/31_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/31_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/31_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/31_naive.jpg


--------------------------------------------------------------------------------
/data/31_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/31_target.jpg


--------------------------------------------------------------------------------
/data/32_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/32_c_mask.jpg


--------------------------------------------------------------------------------
/data/32_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/32_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/32_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/32_naive.jpg


--------------------------------------------------------------------------------
/data/32_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/32_target.jpg


--------------------------------------------------------------------------------
/data/33_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/33_c_mask.jpg


--------------------------------------------------------------------------------
/data/33_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/33_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/33_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/33_naive.jpg


--------------------------------------------------------------------------------
/data/33_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/33_target.jpg


--------------------------------------------------------------------------------
/data/34_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/34_c_mask.jpg


--------------------------------------------------------------------------------
/data/34_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/34_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/34_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/34_naive.jpg


--------------------------------------------------------------------------------
/data/34_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/34_target.jpg


--------------------------------------------------------------------------------
/data/35_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/35_target.jpg


--------------------------------------------------------------------------------
/data/3_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/3_c_mask.jpg


--------------------------------------------------------------------------------
/data/3_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/3_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/3_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/3_naive.jpg


--------------------------------------------------------------------------------
/data/3_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/3_target.jpg


--------------------------------------------------------------------------------
/data/4_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/4_c_mask.jpg


--------------------------------------------------------------------------------
/data/4_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/4_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/4_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/4_naive.jpg


--------------------------------------------------------------------------------
/data/4_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/4_target.jpg


--------------------------------------------------------------------------------
/data/5_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/5_c_mask.jpg


--------------------------------------------------------------------------------
/data/5_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/5_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/5_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/5_naive.jpg


--------------------------------------------------------------------------------
/data/5_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/5_target.jpg


--------------------------------------------------------------------------------
/data/6_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/6_c_mask.jpg


--------------------------------------------------------------------------------
/data/6_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/6_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/6_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/6_naive.jpg


--------------------------------------------------------------------------------
/data/6_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/6_target.jpg


--------------------------------------------------------------------------------
/data/7_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/7_c_mask.jpg


--------------------------------------------------------------------------------
/data/7_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/7_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/7_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/7_naive.jpg


--------------------------------------------------------------------------------
/data/7_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/7_target.jpg


--------------------------------------------------------------------------------
/data/8_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/8_c_mask.jpg


--------------------------------------------------------------------------------
/data/8_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/8_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/8_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/8_naive.jpg


--------------------------------------------------------------------------------
/data/8_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/8_target.jpg


--------------------------------------------------------------------------------
/data/9_c_mask.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/9_c_mask.jpg


--------------------------------------------------------------------------------
/data/9_c_mask_dilated.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/9_c_mask_dilated.jpg


--------------------------------------------------------------------------------
/data/9_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/9_naive.jpg


--------------------------------------------------------------------------------
/data/9_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/data/9_target.jpg


--------------------------------------------------------------------------------
/data/wikiart_output.txt:
--------------------------------------------------------------------------------
 1 | idx=0, classified label=Art Nouveau (Modern), weight=1.203930
 2 | idx=1, classified label=Impressionism, weight=5.323582
 3 | idx=2, classified label=Impressionism, weight=4.234591
 4 | idx=3, classified label=Post-Impressionism, weight=5.498451
 5 | idx=4, classified label=Impressionism, weight=4.910163
 6 | idx=5, classified label=Cubism, weight=9.982656
 7 | idx=6, classified label=Post-Impressionism, weight=5.731922
 8 | idx=7, classified label=Expressionism, weight=9.862515
 9 | idx=8, classified label=Post-Impressionism, weight=5.019980
10 | idx=9, classified label=Expressionism, weight=8.189465
11 | idx=10, classified label=Art Nouveau (Modern), weight=1.340035
12 | idx=11, classified label=Expressionism, weight=9.331765
13 | idx=12, classified label=Post-Impressionism, weight=7.318527
14 | idx=13, classified label=Post-Impressionism, weight=5.106254
15 | idx=14, classified label=Symbolism, weight=1.295220
16 | idx=15, classified label=Baroque, weight=1.001454
17 | idx=16, classified label=Impressionism, weight=1.018541
18 | idx=17, classified label=High Renaissance, weight=1.000000
19 | idx=18, classified label=Impressionism, weight=4.999322
20 | idx=19, classified label=Mannerism (Late Renaissance), weight=1.002947
21 | idx=20, classified label=Romanticism, weight=1.000424
22 | idx=21, classified label=Post-Impressionism, weight=4.953209
23 | idx=22, classified label=Impressionism, weight=4.997079
24 | idx=23, classified label=Expressionism, weight=9.995778
25 | idx=24, classified label=Impressionism, weight=4.800576
26 | idx=25, classified label=Post-Impressionism, weight=5.062284
27 | idx=26, classified label=Realism, weight=1.001287
28 | idx=27, classified label=Post-Impressionism, weight=5.000851
29 | idx=28, classified label=Impressionism, weight=4.977097
30 | idx=29, classified label=Romanticism, weight=2.303986
31 | idx=30, classified label=Post-Impressionism, weight=5.017763
32 | idx=31, classified label=Impressionism, weight=4.983986
33 | idx=32, classified label=Post-Impressionism, weight=4.999594
34 | idx=33, classified label=Realism, weight=1.512768
35 | idx=34, classified label=Baroque, weight=1.036211
36 | 


--------------------------------------------------------------------------------
/dilate_mask.m:
--------------------------------------------------------------------------------
 1 | for i = 0 : 34
 2 |     close all;
 3 |     fn = [int2str(i) '_c_mask.png']
 4 |     I = im2double(imread(fn));
 5 |     [h w c] = size(I);
 6 |     if c == 3 
 7 |         I = I(:,:,1);
 8 |     end 
 9 |     
10 |     h1 = h;
11 |     w1 = w;
12 |     if h ~= 700 && w ~= 700 
13 |         if h > w 
14 |             h1 = 700;
15 |             w1 = floor(h1 * w/h);
16 |         else 
17 |             w1 = 700;
18 |             h1 = floor(w1 * h/w);
19 |         end 
20 |     end 
21 |     
22 |     figure; imshow(I)
23 |     r = 35;
24 |     h = fspecial('gaussian', [r r], r/3);
25 |     J = imfilter(I, h, 'same');
26 |     
27 |     figure; imshow(J)
28 |     J2 = J;
29 |     J2(J>0.1) = 1;
30 |     J2(J<=0.1) = 0;
31 |     figure; imshow(J2)
32 |     imwrite(J2, [int2str(i) '_c_mask_dilated.png']);
33 | end 


--------------------------------------------------------------------------------
/filt_cnn_artifact.m:
--------------------------------------------------------------------------------
 1 | 
 2 | for i = 0:34
 3 |     close all
 4 | 
 5 |     in_fn  = ['results/' int2str(i) '_final_res.png'];
 6 |     out_fn = ['results/' int2str(i) '_final_res2.png'];
 7 |     
 8 |     if exist(in_fn, 'file') ~= 2 
 9 |         fprintf('file doesn''t exist: %s\n', in_fn); 
10 |         continue
11 |     end 
12 |     if exist(out_fn, 'file') == 2 
13 |         fprintf('result already exists: %s\n', out_fn); 
14 |         continue
15 |     end 
16 | 
17 |     I = im2double(imread(in_fn));
18 | 
19 |     G = im2double(imread(['data/' int2str(i) '_naive.jpg']));
20 |     M = im2double(imread(['data/' int2str(i) '_c_mask.jpg']));
21 |     B = im2double(imread(['data/' int2str(i) '_target.jpg']));
22 | 
23 | 
24 |     tr= 3;
25 |     h = fspecial('gaussian', [2*tr+1 2*tr+1], tr);
26 |     sM = imfilter(M, h, 'same'); 
27 |     sM(sM > 0.01) = 1; % dialte
28 |     sM(sM < 0.01) = 0;
29 |     sM = imfilter(sM, h, 'same'); 
30 | 
31 |     addpath 3rdparty/colorspace
32 |     I_lab = colorspace('rgb->lab', I);
33 | 
34 |     addpath 3rdparty/guided_filter
35 |     addpath 3rdparty/patchmatch-2.0
36 | 
37 |     r = 2; % try r=2, 4, or 8
38 |     eps = 0.1^2; % try eps=0.1^2, 0.2^2, 0.4^2
39 | 
40 |     O_lab = I_lab;
41 |     O_lab(:,:,2) = guidedfilter_color(G, I_lab(:,:,2), r, eps);
42 |     O_lab(:,:,3) = guidedfilter_color(G, I_lab(:,:,3), r, eps);
43 | 
44 |     % runs here, deconvolution CNN artifact removed
45 |     O1 = colorspace('lab->rgb', O_lab);
46 |     % one patchmatch pass to further remove color artifact
47 |     cores = 4; 
48 |     algo = 'cputiled';
49 |     patch_w = 7;
50 |     ann = nnmex(O1, B, algo, patch_w, [], [], [], [], [], cores);
51 |     O2_base = im2double(votemex(B, ann));
52 | 
53 |     r = 3;
54 |     h = fspecial('gaussian', [2*r+1 2*r+1], r/3);
55 |     O1_base = imfilter(O1, h, 'same');
56 |     O2 = O2_base + O1 - O1_base;
57 | 
58 |     O2 = O2.*sM + B.*(1-sM);
59 |     figure; imshow(I)
60 |     figure; imshow(O2)
61 | 
62 |     imwrite(O2, out_fn);
63 | end 
64 | 
65 | 
66 | 


--------------------------------------------------------------------------------
/gen_all.py:
--------------------------------------------------------------------------------
 1 | import os
 2 | import math
 3 | 
 4 | numImgs = 35
 5 | # numGpus = 16 
 6 | numGpus = 1
 7 | 
 8 | if os.path.exists('results') == 0:
 9 | 	os.mkdir('results')
10 | 
11 | N = int(math.ceil(float(numImgs)/numGpus))
12 | 
13 | for j in range(1, numGpus+1):
14 | 	cmd = ''
15 | 	for i in range(1, N+1):
16 | 		idx = (i-1) * numGpus + (j-1)
17 | 		if idx >= 0 and idx < numImgs:
18 | 			print('Working on image idx = ', idx)
19 | 			part_cmd1 =' th neural_gram.lua '\
20 | 					   ' -content_image data/' + str(idx) + '_naive.jpg  '\
21 | 					   ' -style_image   data/' + str(idx) + '_target.jpg '\
22 | 					   ' -tmask_image   data/' + str(idx) + '_c_mask.jpg '\
23 | 					   ' -mask_image    data/' + str(idx) + '_c_mask_dilated.jpg '\
24 | 					   ' -gpu ' + str(j-1) + ' -original_colors 0 -image_size 700 '\
25 | 					   ' -output_image  results/' + str(idx) + '_inter_res.jpg'\
26 | 					   ' -print_iter 100 -save_iter 100 && '
27 | 			part_cmd2 =' th neural_paint.lua '\
28 | 					   ' -content_image data/' + str(idx) + '_naive.jpg '\
29 | 					   ' -style_image   data/' + str(idx) + '_target.jpg '\
30 | 					   ' -tmask_image   data/' + str(idx) + '_c_mask.jpg '\
31 | 					   ' -mask_image    data/' + str(idx) + '_c_mask_dilated.jpg '\
32 | 					   ' -cnnmrf_image  results/' + str(idx) + '_inter_res.jpg  '\
33 | 					   ' -gpu ' + str(j-1) + ' -original_colors 0 -image_size 700 '\
34 | 					   ' -index ' + str(idx) + ' -wikiart_fn data/wikiart_output.txt '\
35 | 					   ' -output_image  results/' + str(idx) + '_final_res.jpg' \
36 | 					   ' -print_iter 100 -save_iter 100 '\
37 | 					   ' -num_iterations 1000 &&' 
38 | 			cmd = cmd + part_cmd1 + part_cmd2
39 | 	cmd = cmd[1:len(cmd)-1]
40 | 	print(cmd)
41 | 	os.system(cmd)
42 | 


--------------------------------------------------------------------------------
/makefile:
--------------------------------------------------------------------------------
 1 | # Modify PREFIX and NVCC_PREFIX based on your machine environment
 2 | PREFIX=/home/ubuntu/torch/install
 3 | NVCC_PREFIX=/usr/local/cuda-8.0/bin
 4 | CFLAGS=-I$(PREFIX)/include/THC -I$(PREFIX)/include/TH -I$(PREFIX)/include
 5 | LDFLAGS_NVCC=-L$(PREFIX)/lib -Xlinker -rpath,$(PREFIX)/lib -lluaT -lTHC -lTH -lpng -lluajit -lgomp
 6 | 
 7 | all: libcuda_utils.so 
 8 | 
 9 | libcuda_utils.so: cuda_utils.cu
10 | 	$(NVCC_PREFIX)/nvcc -arch sm_35 -O3 -DNDEBUG -Xcompiler -fopenmp --compiler-options '-fPIC' -o libcuda_utils.so --shared cuda_utils.cu $(CFLAGS) $(LDFLAGS_NVCC)
11 | 
12 | clean:
13 | 	find . -type f | xargs -n 5 touch
14 | 	rm -f libcuda_utils.so  
15 | 


--------------------------------------------------------------------------------
/models/download_models.sh:
--------------------------------------------------------------------------------
1 | cd models
2 | wget -c https://gist.githubusercontent.com/ksimonyan/3785162f95cd2d5fee77/raw/bb2b4fe0a9bb0669211cf3d0bc949dfdda173e9e/VGG_ILSVRC_19_layers_deploy.prototxt
3 | wget -c --no-check-certificate https://bethgelab.org/media/uploads/deeptextures/vgg_normalised.caffemodel
4 | wget -c http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_19_layers.caffemodel
5 | cd ..
6 | 


--------------------------------------------------------------------------------
/results/0_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/0_final_res.png


--------------------------------------------------------------------------------
/results/0_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/0_final_res2.png


--------------------------------------------------------------------------------
/results/0_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/0_inter_res.jpg


--------------------------------------------------------------------------------
/results/10_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/10_final_res.png


--------------------------------------------------------------------------------
/results/10_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/10_final_res2.png


--------------------------------------------------------------------------------
/results/10_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/10_inter_res.jpg


--------------------------------------------------------------------------------
/results/11_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/11_final_res.png


--------------------------------------------------------------------------------
/results/11_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/11_final_res2.png


--------------------------------------------------------------------------------
/results/11_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/11_inter_res.jpg


--------------------------------------------------------------------------------
/results/12_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/12_final_res.png


--------------------------------------------------------------------------------
/results/12_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/12_final_res2.png


--------------------------------------------------------------------------------
/results/12_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/12_inter_res.jpg


--------------------------------------------------------------------------------
/results/13_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/13_final_res.png


--------------------------------------------------------------------------------
/results/13_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/13_final_res2.png


--------------------------------------------------------------------------------
/results/13_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/13_inter_res.jpg


--------------------------------------------------------------------------------
/results/14_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/14_final_res.png


--------------------------------------------------------------------------------
/results/14_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/14_final_res2.png


--------------------------------------------------------------------------------
/results/14_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/14_inter_res.jpg


--------------------------------------------------------------------------------
/results/15_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/15_final_res.png


--------------------------------------------------------------------------------
/results/15_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/15_final_res2.png


--------------------------------------------------------------------------------
/results/15_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/15_inter_res.jpg


--------------------------------------------------------------------------------
/results/16_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/16_final_res.png


--------------------------------------------------------------------------------
/results/16_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/16_final_res2.png


--------------------------------------------------------------------------------
/results/16_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/16_inter_res.jpg


--------------------------------------------------------------------------------
/results/17_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/17_final_res.png


--------------------------------------------------------------------------------
/results/17_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/17_final_res2.png


--------------------------------------------------------------------------------
/results/17_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/17_inter_res.jpg


--------------------------------------------------------------------------------
/results/17_naive_sherlock.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/17_naive_sherlock.jpg


--------------------------------------------------------------------------------
/results/17_result_sherlock.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/17_result_sherlock.jpg


--------------------------------------------------------------------------------
/results/18_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/18_final_res.png


--------------------------------------------------------------------------------
/results/18_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/18_final_res2.png


--------------------------------------------------------------------------------
/results/18_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/18_inter_res.jpg


--------------------------------------------------------------------------------
/results/19_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/19_final_res.png


--------------------------------------------------------------------------------
/results/19_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/19_final_res2.png


--------------------------------------------------------------------------------
/results/19_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/19_inter_res.jpg


--------------------------------------------------------------------------------
/results/1_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/1_final_res.png


--------------------------------------------------------------------------------
/results/1_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/1_final_res2.png


--------------------------------------------------------------------------------
/results/1_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/1_inter_res.jpg


--------------------------------------------------------------------------------
/results/20_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/20_final_res.png


--------------------------------------------------------------------------------
/results/20_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/20_final_res2.png


--------------------------------------------------------------------------------
/results/20_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/20_inter_res.jpg


--------------------------------------------------------------------------------
/results/21_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/21_final_res.png


--------------------------------------------------------------------------------
/results/21_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/21_final_res2.png


--------------------------------------------------------------------------------
/results/21_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/21_inter_res.jpg


--------------------------------------------------------------------------------
/results/22_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/22_final_res.png


--------------------------------------------------------------------------------
/results/22_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/22_final_res2.png


--------------------------------------------------------------------------------
/results/22_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/22_inter_res.jpg


--------------------------------------------------------------------------------
/results/23_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/23_final_res.png


--------------------------------------------------------------------------------
/results/23_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/23_final_res2.png


--------------------------------------------------------------------------------
/results/23_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/23_inter_res.jpg


--------------------------------------------------------------------------------
/results/24_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/24_final_res.png


--------------------------------------------------------------------------------
/results/24_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/24_final_res2.png


--------------------------------------------------------------------------------
/results/24_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/24_inter_res.jpg


--------------------------------------------------------------------------------
/results/25_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/25_final_res.png


--------------------------------------------------------------------------------
/results/25_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/25_final_res2.png


--------------------------------------------------------------------------------
/results/25_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/25_inter_res.jpg


--------------------------------------------------------------------------------
/results/26_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/26_final_res.png


--------------------------------------------------------------------------------
/results/26_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/26_final_res2.png


--------------------------------------------------------------------------------
/results/26_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/26_inter_res.jpg


--------------------------------------------------------------------------------
/results/27_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/27_final_res.png


--------------------------------------------------------------------------------
/results/27_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/27_final_res2.png


--------------------------------------------------------------------------------
/results/27_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/27_inter_res.jpg


--------------------------------------------------------------------------------
/results/28_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/28_final_res.png


--------------------------------------------------------------------------------
/results/28_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/28_final_res2.png


--------------------------------------------------------------------------------
/results/28_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/28_inter_res.jpg


--------------------------------------------------------------------------------
/results/28_naive_cow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/28_naive_cow.png


--------------------------------------------------------------------------------
/results/28_result_cow.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/28_result_cow.jpg


--------------------------------------------------------------------------------
/results/29_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/29_final_res.png


--------------------------------------------------------------------------------
/results/29_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/29_final_res2.png


--------------------------------------------------------------------------------
/results/29_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/29_inter_res.jpg


--------------------------------------------------------------------------------
/results/2_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/2_final_res.png


--------------------------------------------------------------------------------
/results/2_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/2_final_res2.png


--------------------------------------------------------------------------------
/results/2_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/2_inter_res.jpg


--------------------------------------------------------------------------------
/results/30_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/30_final_res.png


--------------------------------------------------------------------------------
/results/30_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/30_final_res2.png


--------------------------------------------------------------------------------
/results/30_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/30_inter_res.jpg


--------------------------------------------------------------------------------
/results/31_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/31_final_res.png


--------------------------------------------------------------------------------
/results/31_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/31_final_res2.png


--------------------------------------------------------------------------------
/results/31_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/31_inter_res.jpg


--------------------------------------------------------------------------------
/results/32_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/32_final_res.png


--------------------------------------------------------------------------------
/results/32_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/32_final_res2.png


--------------------------------------------------------------------------------
/results/32_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/32_inter_res.jpg


--------------------------------------------------------------------------------
/results/33_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/33_final_res.png


--------------------------------------------------------------------------------
/results/33_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/33_final_res2.png


--------------------------------------------------------------------------------
/results/33_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/33_inter_res.jpg


--------------------------------------------------------------------------------
/results/33_naive_buddha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/33_naive_buddha.png


--------------------------------------------------------------------------------
/results/33_result_buddha.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/33_result_buddha.jpg


--------------------------------------------------------------------------------
/results/34_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/34_final_res.png


--------------------------------------------------------------------------------
/results/34_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/34_final_res2.png


--------------------------------------------------------------------------------
/results/34_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/34_inter_res.jpg


--------------------------------------------------------------------------------
/results/35_naive.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/35_naive.jpg


--------------------------------------------------------------------------------
/results/35_result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/35_result.png


--------------------------------------------------------------------------------
/results/3_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/3_final_res.png


--------------------------------------------------------------------------------
/results/3_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/3_final_res2.png


--------------------------------------------------------------------------------
/results/3_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/3_inter_res.jpg


--------------------------------------------------------------------------------
/results/4_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/4_final_res.png


--------------------------------------------------------------------------------
/results/4_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/4_final_res2.png


--------------------------------------------------------------------------------
/results/4_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/4_inter_res.jpg


--------------------------------------------------------------------------------
/results/5_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/5_final_res.png


--------------------------------------------------------------------------------
/results/5_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/5_final_res2.png


--------------------------------------------------------------------------------
/results/5_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/5_inter_res.jpg


--------------------------------------------------------------------------------
/results/6_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/6_final_res.png


--------------------------------------------------------------------------------
/results/6_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/6_final_res2.png


--------------------------------------------------------------------------------
/results/6_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/6_inter_res.jpg


--------------------------------------------------------------------------------
/results/7_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/7_final_res.png


--------------------------------------------------------------------------------
/results/7_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/7_final_res2.png


--------------------------------------------------------------------------------
/results/7_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/7_inter_res.jpg


--------------------------------------------------------------------------------
/results/7_naive_popeye.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/7_naive_popeye.png


--------------------------------------------------------------------------------
/results/7_result_popeye.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/7_result_popeye.jpg


--------------------------------------------------------------------------------
/results/7_target.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/7_target.jpg


--------------------------------------------------------------------------------
/results/8_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/8_final_res.png


--------------------------------------------------------------------------------
/results/8_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/8_final_res2.png


--------------------------------------------------------------------------------
/results/8_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/8_inter_res.jpg


--------------------------------------------------------------------------------
/results/8_naive_aircraft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/8_naive_aircraft.png


--------------------------------------------------------------------------------
/results/8_naive_balloon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/8_naive_balloon.jpg


--------------------------------------------------------------------------------
/results/8_result_aircraft.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/8_result_aircraft.png


--------------------------------------------------------------------------------
/results/8_result_balloon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/8_result_balloon.jpg


--------------------------------------------------------------------------------
/results/9_final_res.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/9_final_res.png


--------------------------------------------------------------------------------
/results/9_final_res2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/9_final_res2.png


--------------------------------------------------------------------------------
/results/9_inter_res.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/9_inter_res.jpg


--------------------------------------------------------------------------------
/results/9_naive_dragon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/9_naive_dragon.png


--------------------------------------------------------------------------------
/results/9_result_dragon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luanfujun/deep-painterly-harmonization/a33a9a70366b6baff1cc0291f857b5895b271fc1/results/9_result_dragon.jpg


--------------------------------------------------------------------------------