RGB的像素值都在[0,255],如果我们想给一个250的像素再加十个像素会怎么样?
NumPy将执行模算术和“环绕”。比如250 再加10像素,会绕回到4,
OpenCV 将执行剪切并确保像素值永远不会超出范围[0,255]
NumPy will perform modulo arithmetic and “wrap around”.
OpenCV, on the other hand, will perform clipping and ensure pixel values never fall outside the range [0, 255].
1 | from __future__ import print_function |
运行结果如下:
1 | M =np.ones(image.shape, dtype="uint8")*100 |
一件事情的毕业,永远是另一件事情的开启.