-
Notifications
You must be signed in to change notification settings - Fork 1
/
synth_texture.h
72 lines (54 loc) · 1.72 KB
/
synth_texture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef SYNTH__TEXTURE__H
#define SYNTH__TEXTURE__H
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <iostream>
#include "NL/nl.h"
#include <math.h>
using namespace cv;
using namespace std;
#define COLOR_BW 1
#define COLOR_RGB 3
class synth_texture{
private:
Mat raw_image; // input texture
int out_width, out_height, in_width, in_height;
int grid_step, scale; // grid parameter, also half neighborhood width
Size out_size,current_size_out, current_size_in;// size of the wanted/current synthetized image
public:
Mat image; // input texture, rescaled as needed
Mat out_image; // output image
Mat Zp; // source patch position for each pixel
int max_iter;
Size size; // the size we want in the end
Mat features;
int pixelsInNeighborhood;
int numData;
// constructor
synth_texture(Mat texture, Size size);
// create new image
void synthetize();
flann::Index kdtree_shared;
private:
// get pixels surrounding as a vector
Mat extract_neighborhood(Mat M, int h, int v);
// ENERGY
double energy, energy_previous;
// Pixels are changed to minimize energy
void minimize_energy();
// send initial guess to OpenNL internals
void image_to_solver();
// recover solution from OpenNL internals
void solver_to_image();
// send image information to solver
void setup_matrix();
// SOURCES
Mat out_image_bw, image_bw;
int color; // 1: BW, 3:Color
void update_neighborhoods();
// MULTISCALE
int level; // where are we in the multi-scale optimization ?
// when no more progress is made, be more local or initilize a bigger image
void update_level(int level);
};
#endif