-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSurfaceNormalMap.h
More file actions
77 lines (52 loc) · 1.63 KB
/
SurfaceNormalMap.h
File metadata and controls
77 lines (52 loc) · 1.63 KB
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
73
74
75
76
#ifndef SURFACE_NORMAL_MAP_H
#define SURFACE_NORMAL_MAP_H
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <limits>
#include "pgm/Image.h"
#include "Validation.h"
#include "Matrix.h"
using namespace std;
void drawBorder(Image* img, int r, int c, int color);
class SurfaceNormalMap{
public:
SurfaceNormalMap(const char* dirs_fname, vector<Image*> obj_imgs, int step, int threshold) : images(obj_imgs) {
setLightSourcesFromFile(dirs_fname);
generateGridPoints(step, threshold);
};
SurfaceNormalMap(const char* dirs_fname, vector<Image*> obj_imgs, int threshold) : images(obj_imgs) {
setLightSourcesFromFile(dirs_fname);
generateAlbedoMap(threshold);
};
~SurfaceNormalMap(){
delete light_sources;
}
void drawNormalMap(Image* output_img){
drawGridPoints(output_img);
calcAndDrawNormals(output_img);
}
void shadeWithAlbedo(Image* output_img){
shadeAlbedo(output_img);
}
private:
Matrix* light_sources;
Matrix light_sources_inverse;
vector< pair<int, int> > grid_points;
vector<Image*> images;
vector< vector<float> > albedo_map;
float max_albedo;
void setLightSourcesFromFile(const char* fname);
void generateGridPoints(int step, int threshold);
bool visibleInAllImages(int r, int c, int threshold);
void drawGridPoints(Image* output_img);
void calcAndDrawNormals(Image* output_img);
Matrix calcAlbedoNormal(int r, int c);
Matrix calcNormal(int r, int c);
void drawNormal(int r, int c, Matrix normal, Image* img);
float calcAlbedo(int r, int c);
void generateAlbedoMap(int threshold);
void shadeAlbedo(Image* output_img);
};
#endif