Commit e027979474123254be5ec860749e58496a91e603

Authored by Josh Klontz
1 parent 968f94f3

fix Bin transform to correctly round integral types

Showing 1 changed file with 2 additions and 1 deletions
openbr/plugins/hist.cpp
@@ -83,7 +83,8 @@ class BinTransform : public UntrainableTransform @@ -83,7 +83,8 @@ class BinTransform : public UntrainableTransform
83 83
84 void project(const Template &src, Template &dst) const 84 void project(const Template &src, Template &dst) const
85 { 85 {
86 - src.m().convertTo(dst, bins > 256 ? CV_16U : CV_8U, bins/(max-min), -0.5 /* floor */); 86 + const double floor = ((src.m().depth() == CV_32F) || (src.m().depth() == CV_64F)) ? -0.5 : 0;
  87 + src.m().convertTo(dst, bins > 256 ? CV_16U : CV_8U, bins/(max-min), floor);
87 if (!split) return; 88 if (!split) return;
88 89
89 Mat input = dst; 90 Mat input = dst;