mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Changed LUTs from IT to int
This commit is contained in:
parent
305cff36e2
commit
18be52c05b
@ -75,9 +75,9 @@ private:
|
|||||||
int template_window_half_size_;
|
int template_window_half_size_;
|
||||||
int search_window_half_size_;
|
int search_window_half_size_;
|
||||||
|
|
||||||
IT fixed_point_mult_;
|
int fixed_point_mult_;
|
||||||
int almost_template_window_size_sq_bin_shift_;
|
int almost_template_window_size_sq_bin_shift_;
|
||||||
std::vector<IT> almost_dist2weight_;
|
std::vector<int> almost_dist2weight_;
|
||||||
|
|
||||||
void calcDistSumsForFirstElementInRow(
|
void calcDistSumsForFirstElementInRow(
|
||||||
int i, Array2d<int>& dist_sums,
|
int i, Array2d<int>& dist_sums,
|
||||||
@ -119,7 +119,8 @@ FastNlMeansDenoisingInvoker<T, IT, UIT, D>::FastNlMeansDenoisingInvoker(
|
|||||||
|
|
||||||
const IT max_estimate_sum_value =
|
const IT max_estimate_sum_value =
|
||||||
(IT)search_window_size_ * (IT)search_window_size_ * (IT)pixelInfo<T>::sampleMax();
|
(IT)search_window_size_ * (IT)search_window_size_ * (IT)pixelInfo<T>::sampleMax();
|
||||||
fixed_point_mult_ = std::numeric_limits<IT>::max() / max_estimate_sum_value;
|
fixed_point_mult_ = (int)std::min<IT>(std::numeric_limits<IT>::max() / max_estimate_sum_value,
|
||||||
|
std::numeric_limits<int>::max());
|
||||||
|
|
||||||
// precalc weight for every possible l2 dist between blocks
|
// precalc weight for every possible l2 dist between blocks
|
||||||
// additional optimization of precalced weights to replace division(averaging) by binary shift
|
// additional optimization of precalced weights to replace division(averaging) by binary shift
|
||||||
@ -136,7 +137,7 @@ FastNlMeansDenoisingInvoker<T, IT, UIT, D>::FastNlMeansDenoisingInvoker(
|
|||||||
for (int almost_dist = 0; almost_dist < almost_max_dist; almost_dist++)
|
for (int almost_dist = 0; almost_dist < almost_max_dist; almost_dist++)
|
||||||
{
|
{
|
||||||
double dist = almost_dist * almost_dist2actual_dist_multiplier;
|
double dist = almost_dist * almost_dist2actual_dist_multiplier;
|
||||||
IT weight = (IT)round(fixed_point_mult_ * D::template calcWeight<T>(dist, h));
|
int weight = (int)round(fixed_point_mult_ * D::template calcWeight<T>(dist, h));
|
||||||
if (weight < WEIGHT_THRESHOLD * fixed_point_mult_)
|
if (weight < WEIGHT_THRESHOLD * fixed_point_mult_)
|
||||||
weight = 0;
|
weight = 0;
|
||||||
|
|
||||||
@ -238,8 +239,8 @@ void FastNlMeansDenoisingInvoker<T, IT, UIT, D>::operator() (const Range& range)
|
|||||||
for (int x = 0; x < search_window_size_; x++)
|
for (int x = 0; x < search_window_size_; x++)
|
||||||
{
|
{
|
||||||
int almostAvgDist = dist_sums_row[x] >> almost_template_window_size_sq_bin_shift_;
|
int almostAvgDist = dist_sums_row[x] >> almost_template_window_size_sq_bin_shift_;
|
||||||
IT weight = almost_dist2weight_[almostAvgDist];
|
int weight = almost_dist2weight_[almostAvgDist];
|
||||||
weights_sum += weight;
|
weights_sum += (IT)weight;
|
||||||
|
|
||||||
T p = cur_row_ptr[border_size_ + search_window_x + x];
|
T p = cur_row_ptr[border_size_ + search_window_x + x];
|
||||||
incWithWeight<T, IT>(estimation, weight, p);
|
incWithWeight<T, IT>(estimation, weight, p);
|
||||||
|
@ -253,39 +253,39 @@ public:
|
|||||||
|
|
||||||
template <typename T, typename IT> struct incWithWeight_
|
template <typename T, typename IT> struct incWithWeight_
|
||||||
{
|
{
|
||||||
static inline void f(IT* estimation, IT weight, T p)
|
static inline void f(IT* estimation, int weight, T p)
|
||||||
{
|
{
|
||||||
estimation[0] += weight * p;
|
estimation[0] += (IT)weight * p;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ET, typename IT> struct incWithWeight_<Vec<ET, 2>, IT>
|
template <typename ET, typename IT> struct incWithWeight_<Vec<ET, 2>, IT>
|
||||||
{
|
{
|
||||||
static inline void f(IT* estimation, IT weight, Vec<ET, 2> p)
|
static inline void f(IT* estimation, int weight, Vec<ET, 2> p)
|
||||||
{
|
{
|
||||||
estimation[0] += weight * p[0];
|
estimation[0] += (IT)weight * p[0];
|
||||||
estimation[1] += weight * p[1];
|
estimation[1] += (IT)weight * p[1];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ET, typename IT> struct incWithWeight_<Vec<ET, 3>, IT>
|
template <typename ET, typename IT> struct incWithWeight_<Vec<ET, 3>, IT>
|
||||||
{
|
{
|
||||||
static inline void f(IT* estimation, IT weight, Vec<ET, 3> p)
|
static inline void f(IT* estimation, int weight, Vec<ET, 3> p)
|
||||||
{
|
{
|
||||||
estimation[0] += weight * p[0];
|
estimation[0] += (IT)weight * p[0];
|
||||||
estimation[1] += weight * p[1];
|
estimation[1] += (IT)weight * p[1];
|
||||||
estimation[2] += weight * p[2];
|
estimation[2] += (IT)weight * p[2];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ET, typename IT> struct incWithWeight_<Vec<ET, 4>, IT>
|
template <typename ET, typename IT> struct incWithWeight_<Vec<ET, 4>, IT>
|
||||||
{
|
{
|
||||||
static inline void f(IT* estimation, IT weight, Vec<ET, 4> p)
|
static inline void f(IT* estimation, int weight, Vec<ET, 4> p)
|
||||||
{
|
{
|
||||||
estimation[0] += weight * p[0];
|
estimation[0] += (IT)weight * p[0];
|
||||||
estimation[1] += weight * p[1];
|
estimation[1] += (IT)weight * p[1];
|
||||||
estimation[2] += weight * p[2];
|
estimation[2] += (IT)weight * p[2];
|
||||||
estimation[3] += weight * p[3];
|
estimation[3] += (IT)weight * p[3];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,9 +81,9 @@ private:
|
|||||||
int search_window_half_size_;
|
int search_window_half_size_;
|
||||||
int temporal_window_half_size_;
|
int temporal_window_half_size_;
|
||||||
|
|
||||||
IT fixed_point_mult_;
|
int fixed_point_mult_;
|
||||||
int almost_template_window_size_sq_bin_shift;
|
int almost_template_window_size_sq_bin_shift;
|
||||||
std::vector<IT> almost_dist2weight;
|
std::vector<int> almost_dist2weight;
|
||||||
|
|
||||||
void calcDistSumsForFirstElementInRow(int i, Array3d<int>& dist_sums,
|
void calcDistSumsForFirstElementInRow(int i, Array3d<int>& dist_sums,
|
||||||
Array4d<int>& col_dist_sums,
|
Array4d<int>& col_dist_sums,
|
||||||
@ -127,7 +127,8 @@ FastNlMeansMultiDenoisingInvoker<T, IT, UIT, D>::FastNlMeansMultiDenoisingInvoke
|
|||||||
main_extended_src_ = extended_srcs_[temporal_window_half_size_];
|
main_extended_src_ = extended_srcs_[temporal_window_half_size_];
|
||||||
const IT max_estimate_sum_value =
|
const IT max_estimate_sum_value =
|
||||||
(IT)temporal_window_size_ * (IT)search_window_size_ * (IT)search_window_size_ * (IT)pixelInfo<T>::sampleMax();
|
(IT)temporal_window_size_ * (IT)search_window_size_ * (IT)search_window_size_ * (IT)pixelInfo<T>::sampleMax();
|
||||||
fixed_point_mult_ = std::numeric_limits<IT>::max() / max_estimate_sum_value;
|
fixed_point_mult_ = (int)std::min<IT>(std::numeric_limits<IT>::max() / max_estimate_sum_value,
|
||||||
|
std::numeric_limits<int>::max());
|
||||||
|
|
||||||
// precalc weight for every possible l2 dist between blocks
|
// precalc weight for every possible l2 dist between blocks
|
||||||
// additional optimization of precalced weights to replace division(averaging) by binary shift
|
// additional optimization of precalced weights to replace division(averaging) by binary shift
|
||||||
@ -147,7 +148,7 @@ FastNlMeansMultiDenoisingInvoker<T, IT, UIT, D>::FastNlMeansMultiDenoisingInvoke
|
|||||||
for (int almost_dist = 0; almost_dist < almost_max_dist; almost_dist++)
|
for (int almost_dist = 0; almost_dist < almost_max_dist; almost_dist++)
|
||||||
{
|
{
|
||||||
double dist = almost_dist * almost_dist2actual_dist_multiplier;
|
double dist = almost_dist * almost_dist2actual_dist_multiplier;
|
||||||
IT weight = (IT)round(fixed_point_mult_ * D::template calcWeight<T>(dist, h));
|
int weight = (int)round(fixed_point_mult_ * D::template calcWeight<T>(dist, h));
|
||||||
if (weight < WEIGHT_THRESHOLD * fixed_point_mult_)
|
if (weight < WEIGHT_THRESHOLD * fixed_point_mult_)
|
||||||
weight = 0;
|
weight = 0;
|
||||||
|
|
||||||
@ -266,8 +267,8 @@ void FastNlMeansMultiDenoisingInvoker<T, IT, UIT, D>::operator() (const Range& r
|
|||||||
{
|
{
|
||||||
int almostAvgDist = dist_sums_row[x] >> almost_template_window_size_sq_bin_shift;
|
int almostAvgDist = dist_sums_row[x] >> almost_template_window_size_sq_bin_shift;
|
||||||
|
|
||||||
IT weight = almost_dist2weight[almostAvgDist];
|
int weight = almost_dist2weight[almostAvgDist];
|
||||||
weights_sum += weight;
|
weights_sum += (IT)weight;
|
||||||
|
|
||||||
T p = cur_row_ptr[border_size_ + search_window_x + x];
|
T p = cur_row_ptr[border_size_ + search_window_x + x];
|
||||||
incWithWeight<T, IT>(estimation, weight, p);
|
incWithWeight<T, IT>(estimation, weight, p);
|
||||||
|
Loading…
Reference in New Issue
Block a user