18 #ifndef PIC_FILTERING_FILTER_ASSEMBLE_HDR_HPP 19 #define PIC_FILTERING_FILTER_ASSEMBLE_HDR_HPP 21 #include "../filtering/filter.hpp" 23 #include "../util/array.hpp" 25 #include "../algorithms/camera_response_function.hpp" 59 int width = dst->
width;
62 int n = int(src.size());
64 float t_min = src[0]->exposure;
66 for(
int j = 1; j < n; j++) {
67 if(src[j]->exposure < t_min) {
68 t_min = src[j]->exposure;
73 float *acc =
new float[channels];
74 float *totWeight =
new float[channels];
76 for(
int j = box->
y0; j < box->y1; j++) {
79 for(
int i = box->
x0; i < box->x1; i++) {
80 int c = (ind + i) * channels;
85 float max_val_saturation = 1.0f;
86 float max_val_saturation_fb = -1.0f;
89 for(
int l = 0; l < n; l++) {
94 float t_mvs = x / t_min;
96 max_val_saturation_fb =
MAX(max_val_saturation_fb, t_mvs);
99 max_val_saturation = t_mvs;
105 weight *= (src[l]->exposure * src[l]->exposure);
108 for(
int k = 0; k < channels; k++) {
109 float x_lin =
crf->
remove(src[l]->data[c + k], k);
114 acc[k] += (weight * x_lin) / src[l]->exposure;
118 acc[k] += weight * (logf(x_lin +
delta_value) - logf(src[l]->exposure));
122 acc[k] += (weight * x_lin) * src[l]->exposure;
126 totWeight[k] += weight;
130 bool bSaturated =
false;
131 for(
int k = 0; k < channels; k++) {
132 bSaturated = bSaturated || (totWeight[k] < 1e-4
f);
136 for(
int k = 0; k < channels; k++) {
137 acc[k] /= totWeight[k];
139 acc[k] = expf(acc[k]);
141 dst->
data[c + k] = acc[k];
144 max_val_saturation =
MAX(max_val_saturation_fb, max_val_saturation);
168 this->delta_value = 1.0 / 65536.0f;
float remove(float x, int channel)
remove linearizes a camera value using the inverse CRF.
Definition: camera_response_function.hpp:205
The BBox class manages the creation of bounding boxes for images.
Definition: bbox.hpp:29
HDR_REC_DOMAIN
The HDR_REC_DOMAIN enum HRD_LOG: assembling HDR image in the log-domain.
Definition: filter_assemble_hdr.hpp:38
float delta_value
Definition: filter_assemble_hdr.hpp:49
Definition: filter_assemble_hdr.hpp:38
float * data
data is the main buffer where pixel values are stored.
Definition: image.hpp:91
FilterAssembleHDR(CameraResponseFunction *crf=NULL, CRF_WEIGHT weight_type=CW_DEB97, HDR_REC_DOMAIN domain=HRD_LOG)
FilterAssembleHDR.
Definition: filter_assemble_hdr.hpp:162
int channels
Definition: image.hpp:80
std::vector< Image * > ImageVec
ImageVec an std::vector of pic::Image.
Definition: image_vec.hpp:29
int x0
Definition: bbox.hpp:32
The Filter class.
Definition: filter.hpp:50
float channelsf
Definition: image.hpp:84
void ProcessBBox(Image *dst, ImageVec src, BBox *box)
ProcessBBox.
Definition: filter_assemble_hdr.hpp:57
int y0
Definition: bbox.hpp:32
CRF_WEIGHT weight_type
Definition: filter_assemble_hdr.hpp:48
int minInputImages
Definition: filter_radial_basis_function.hpp:56
The FilterAssembleHDR class.
Definition: filter_assemble_hdr.hpp:43
Definition: filter_assemble_hdr.hpp:38
void update(CameraResponseFunction *crf, CRF_WEIGHT weight_type=CW_DEB97, HDR_REC_DOMAIN domain=HRD_LOG)
update
Definition: filter_assemble_hdr.hpp:177
static T sum(T *data, int size)
sum
Definition: array.hpp:416
Definition: filter_assemble_hdr.hpp:38
The CameraResponseFunction class.
Definition: camera_response_function.hpp:48
Definition: weight_function.hpp:28
HDR_REC_DOMAIN domain
Definition: filter_assemble_hdr.hpp:47
PIC_INLINE float weightFunction(float x, CRF_WEIGHT type)
weightFunction computes weight functions for x in [0,1].
Definition: weight_function.hpp:36
The Image class stores an image as buffer of float.
Definition: image.hpp:60
virtual void f(FilterFData *data)
f
Definition: filter_radial_basis_function.hpp:69
Definition: bilateral_separation.hpp:25
static T * assign(T *data, int size, T *ret)
assign
Definition: array.hpp:464
#define MAX(a, b)
Definition: math.hpp:73
int width
Definition: image.hpp:80
CameraResponseFunction * crf
Definition: filter_assemble_hdr.hpp:46
CRF_WEIGHT
The CRF_WEIGHT enum.
Definition: weight_function.hpp:28