float sigma;
// ...
int kernel_size = ((6.0 * sigma) % 2 == 0) ? (6 * sigma + 1) : (6 * sigma);
在这一行中,我想使用三元运算符获得大于6 * sigma值的最小整数。顺便说一句,西格玛是浮动的。
expression must have integral type
。您的代码肯定是错误的,因为它不会编译。
使用ceil(x)
(返回不小于的最小整数x
),您的计算可以像这样完成:
float sigma;
// ...
float s6 = 6.0 * sigma;
float c = ceil(s6);
int kernel_size = c == s6 ? c + 1 : c;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句