QTrk
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
BenchmarkLUT Class Reference

#include <BenchmarkLUT.h>

Public Member Functions

 BenchmarkLUT ()
 
 BenchmarkLUT (ImageData *lut)
 
 BenchmarkLUT (const char *file)
 
void Load (ImageData *lut)
 
void Load (const char *file)
 
void GenerateLUT (ImageData *lut)
 
void GenerateSample (ImageData *image, vector3f pos, float minRadius, float maxRadius)
 

Static Public Member Functions

static void CleanupLUT (ImageData &lut)
 

Public Attributes

std::vector< float > normprof
 
float max_a
 
float max_b
 
float max_c
 
int lut_w
 
int lut_h
 

Detailed Description

Definition at line 7 of file BenchmarkLUT.h.

Constructor & Destructor Documentation

§ BenchmarkLUT() [1/3]

BenchmarkLUT::BenchmarkLUT ( )
inline

Definition at line 15 of file BenchmarkLUT.h.

15 { lut_w=lut_h=0; }

§ BenchmarkLUT() [2/3]

BenchmarkLUT::BenchmarkLUT ( ImageData lut)

Definition at line 10 of file BenchmarkLUT.cpp.

11 {
12  Load(lut);
13 }
void Load(ImageData *lut)

§ BenchmarkLUT() [3/3]

BenchmarkLUT::BenchmarkLUT ( const char *  file)

Definition at line 5 of file BenchmarkLUT.cpp.

6 {
7  Load(file);
8 }
void Load(ImageData *lut)

Member Function Documentation

§ CleanupLUT()

void BenchmarkLUT::CleanupLUT ( ImageData lut)
static

Definition at line 101 of file BenchmarkLUT.cpp.

102 {
103  BenchmarkLUT bm(&lut);
104  bm.GenerateLUT(&lut);
105 }

§ GenerateLUT()

void BenchmarkLUT::GenerateLUT ( ImageData lut)

Definition at line 70 of file BenchmarkLUT.cpp.

71 {
72  float M = lut->w / (float)lut_w;
73 
74  for (int y=0;y<lut->h;y++) {
75  for (int x=0;x<lut->w;x++) {
76  float maxline=M*(max_a*y*y+max_b*y+max_c)/max_c;
77  lut->at(x,y) = Interpolate1D(normprof, x/maxline);
78  }
79  }
80 }
int h
Definition: utils.h:81
T & at(int x, int y)
Definition: utils.h:96
T Interpolate1D(T *d, int len, float x)
Definition: utils.h:64
std::vector< float > normprof
Definition: BenchmarkLUT.h:10
int w
Definition: utils.h:81

§ GenerateSample()

void BenchmarkLUT::GenerateSample ( ImageData image,
vector3f  pos,
float  minRadius,
float  maxRadius 
)

Definition at line 82 of file BenchmarkLUT.cpp.

83 {
84  float radialDensity=lut_w / (maxRadius-minRadius);
85 
86  if(pos.z<0.0f) pos.z=0.0f;
87  if(pos.z>lut_h-1) pos.z=lut_h-1;
88 
89  for (int y=0;y<image->h;y++)
90  for (int x=0;x<image->w;x++)
91  {
92  float dx=x-pos.x;
93  float dy=y-pos.y;
94  float r = (sqrt(dx*dx+dy*dy)-minRadius)*radialDensity; // r in original radial bin pixels
95  float maxline=(max_a*pos.z*pos.z+max_b*pos.z+max_c)/max_c;
96  float profpos = r / maxline;
97  image->at(x,y) = Interpolate1D(normprof, profpos);
98  }
99 }
vector3< T > sqrt(const vector3< T > &a)
Definition: std_incl.h:112
int h
Definition: utils.h:81
T & at(int x, int y)
Definition: utils.h:96
T Interpolate1D(T *d, int len, float x)
Definition: utils.h:64
std::vector< float > normprof
Definition: BenchmarkLUT.h:10
int w
Definition: utils.h:81

§ Load() [1/2]

void BenchmarkLUT::Load ( ImageData lut)

Definition at line 22 of file BenchmarkLUT.cpp.

23 {
24  std::vector<float> max_x,max_y;
25 
26  lut_w = lut->w;
27  lut_h = lut->h;
28 
29  for (int i=lut->h/5;i<lut->h*3/4;i++) {
30  int maxpos = 0;
31  float maxval = lut->at(0, i);
32  for (int x=1;x<lut->w;x++)
33  if (maxval < lut->at(x,i)) {
34  maxval = lut->at(x,i);
35  maxpos=x;
36  }
37  max_x.push_back(maxpos);
38  max_y.push_back(i);
39  }
40 
41  LsqSqQuadFit<float> fit(max_x.size(), &max_y[0],&max_x[0]);
42 
43  max_a = fit.a;
44  max_b = fit.b;
45  max_c = fit.c; //normalized
46 
47  std::vector<int> numsmp(lut->w);
48  normprof.resize(lut->w);
49  for (int r=0;r<lut->w;r++) {
50  float sum=0.0f;
51  int nsmp=0;
52  for (int y=0;y<lut->h;y++) {
53  float x=r*fit.compute(y)/fit.c;
54  bool outside=false;
55  float v = lut->interpolate(x,y,&outside);
56  if (!outside) {
57  sum+=v;
58  nsmp++;
59  }
60  }
61  numsmp[r]=nsmp;
62  normprof[r]=sum;
63  }
64  for (int i=0;i<lut->w;i++) {
65  if (numsmp[i] == 0 && i>0) normprof[i]=normprof[i-1];
66  else normprof[i]=normprof[i]/numsmp[i];
67  }
68 }
T interpolate(float x, float y, bool *outside=0)
Definition: utils.h:97
int h
Definition: utils.h:81
T & at(int x, int y)
Definition: utils.h:96
std::vector< float > normprof
Definition: BenchmarkLUT.h:10
int w
Definition: utils.h:81

§ Load() [2/2]

void BenchmarkLUT::Load ( const char *  file)

Definition at line 15 of file BenchmarkLUT.cpp.

16 {
17  ImageData d = ReadJPEGFile(file);
18  Load(&d);
19  d.free();
20 }
void free()
Definition: utils.h:111
int ReadJPEGFile(uchar *srcbuf, int srclen, uchar **data, int *width, int *height)
Definition: fastjpg.cpp:12
void Load(ImageData *lut)

Member Data Documentation

§ lut_h

int BenchmarkLUT::lut_h

Definition at line 13 of file BenchmarkLUT.h.

§ lut_w

int BenchmarkLUT::lut_w

Definition at line 13 of file BenchmarkLUT.h.

§ max_a

float BenchmarkLUT::max_a

Definition at line 11 of file BenchmarkLUT.h.

§ max_b

float BenchmarkLUT::max_b

Definition at line 11 of file BenchmarkLUT.h.

§ max_c

float BenchmarkLUT::max_c

Definition at line 11 of file BenchmarkLUT.h.

§ normprof

std::vector<float> BenchmarkLUT::normprof

Definition at line 10 of file BenchmarkLUT.h.


The documentation for this class was generated from the following files: