python - Python 中的 OpenCV mat::convertTo

标签 python opencv

OpenCV python 包装器中是否有与 OpenCV 2 中 Mat 的 convertTo 方法相同的功能?

我基本上是想在python中调用这个函数

out.convertTo( out, CV_32F, 1.0/255, 0 );

out 是灰度图像。

我已经通过将我的 dst 参数保持为 CV_32FC1 类型来使用 cv.ConvertScale,但我试图让我的 python 代码尽可能地符合 cv2。有什么线索吗?

最佳答案

您可以简单地使用 Numpy 函数。

例如:

res = np.float32(out)

缩放,你必须单独做:

res = res*scaling_factor

关于python - Python 中的 OpenCV mat::convertTo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16162227/

相关文章:

python - 是否有一种python方式从列表或numpy数组中采样N个连续元素

python - 将叶子与背景分开

matlab - 快速图像扫描

即使在项目中包含 opencv sdk 并添加依赖项后,android 应用程序也会要求安装 OpencvManager

c++ - cvCreateFileCapture()

python - DataFrame.to_dict 为什么会在调用时返回不同的值?

python - 如何在 lr_scheduler LambdaLR 中设置最小学习率?

python - 导入错误: cannot import name GLM

python - 理解 Tensorflow 控制依赖

c++ - 警告 : Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl. hpp:578)