forked from jwetzl/MAPSuperresolution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HuberLaplacian.h
56 lines (45 loc) · 1.59 KB
/
HuberLaplacian.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
/**
* ___ _ _ ___ _ __ __ _ ___
* / __| | | | \ /_\ | \/ | /_\ | _ \
* | (__| |_| | |) / _ \ | |\/| |/ _ \| _/
* \___|\___/|___/_/_\_\_|_|__|_/_/_\_\_|_ ___
* / __| | | | _ \ __| _ \___| _ \ __/ __|
* \__ \ |_| | _/ _|| /___| / _|\__ \
* |___/\___/|_| |___|_|_\ |_|_\___|___/
* 2012
*
* by Jens Wetzl ([email protected])
* and Oliver Taubmann ([email protected])
*
* This work is licensed under a Creative Commons
* Attribution 3.0 Unported License. (CC-BY)
* http://creativecommons.org/licenses/by/3.0/
*
**/
#ifndef HUBERLOG_H
#define HUBERLOG_H
#include <CudaLBFGS/cost_function.h>
#include <CudaLBFGS/timer.h>
// A prior function on the high resolution image.
// Filters the image using a discrete Laplacian, then
// computes the pseudo-Huber loss function on the result.
class HuberLaplacian : public cost_function
{
public:
HuberLaplacian(const size_t height, const size_t width,
const float alpha = 0.05f, const float strength = 5.0f);
virtual ~HuberLaplacian();
// Computes function value (d_f) and gradient (d_gradf)
// at the given positon (d_x), all in device memory.
virtual void f_gradf(const float *d_x, float *d_f, float *d_gradf);
private:
size_t m_width; // Width of the image
size_t m_height; // Height of the image
float m_alpha; // Huber threshold
float m_strength; // Prior strength (weight in the cost function)
timer *m_atomic;
timer *m_filter;
float *m_reductionArray;
float *m_reductionArray2;
};
#endif // HUBERLOG_H