【发布时间】:2013-11-25 23:29:54
【问题描述】:
这是我在一本书中读到的OpenCV中基本颜色减少的公式。
//p is the value of the channel of a pixel
//n is the reduction factor
p = (p/n)*n + n/2; //integer division
我了解第一个表达式(p/n)*n 是小于或等于p 的n 的第一个倍数。我认为这足以减少n 的颜色。但我不明白添加n/2 有什么需要。
还有,如果p=255和n=5,这个公式会尝试设置p = 257,会不会超出p的范围?
请解释一下。
【问题讨论】:
-
您可以为这本书添加名称吗? (p/n)*n 完全没有意义。
-
OpenCV 2 计算机视觉应用程序编程食谱 - Robert Laganiere
-
整数除法,OK。
-
是的,我之前忘了提。
标签: c++ c algorithm opencv colors