opencv - How does the "compressed form" of `cv::convertMaps` work?
问题描述
The documentation for convertMaps
says that it supports the following transformation:
(CV_32FC1, CV_32FC1)→(CV_16SC2, CV_16UC1)
This is the most frequently used conversion operation, in which the original floating-point maps (seeremap
) are converted to a more compact and much faster fixed-point representation. The first output array contains the rounded coordinates and the second array (created only whennninterpolation=false
) contains indices in the interpolation tables.
I understand that (CV_32FC1, CV_32FC1)
is encoding (x, y)
coordinates as floats. How does the fixed point format work? What is encoded in each 2-channel entry of the CV_16SC2
matrix? What interpolation tables does the CV_16UC1
matrix index into?
解决方案
我会按照我上次调查时记得的内容进行。一粒盐等等。
定点格式将 (x,y) 坐标的整数和小数部分拆分为不同的地图。
它是“紧凑的”,即CV_32FC2
2xCV_32FC1
每个像素使用 8 个字节,而每个像素CV_16SC2 + CV_16UC1
使用 6 个字节。它也是仅整数,因此使用它可以释放浮点计算资源用于其他工作。
整数部分进入第一个映射,即 2 通道。那里没有惊喜。
小数部分被转换为 5 位整数,即它们乘以 32。然后将它们打包在一起,从一个坐标开始的最低 5 位,从另一个坐标开始的高 5 位。
生成的有趣数字的范围为0 .. 1023
或0b00000_00000 .. 0b11111_11111
,分别编码小数部分 (0.0, 0.0) 和 (0.96875, 0.96875)(即 31/32)。
在重新映射期间...
整数映射用于为每个结果像素查找源图像中插值所需的几个像素。
分数图被视为“插值表”的索引,该表是 OpenCV 内部的。它包含将几个采样像素正确混合为一个结果像素所需的任何因素和变化,所有这些都使用整数数学。我想有多个表,每个插值方法(线性,三次,...)一个。
推荐阅读
- google-apps-script - TypeError: sheet.newChart(...).setChartType(...).setDataViewDefinition 不是函数
- php - 注意:PHP 中只能通过引用返回变量引用
- google-cloud-platform - 具有递归选项的 gsutil 保留
- django - 管理侧边栏“突然出现”并导致界面崩溃
- ios - Swift 如何将 String 从类转换为 @State String 变量?
- javascript - 无法在 Rails 应用程序中使用缩小的 vue 组件包
- google-cloud-platform - 错误:尝试添加磁盘时,“Compute API”需要“Alpha Access”权限
- kivy - 如何为标签中的文本设置边框?
- c# - 限制球员轮换
- python - 告诉 Atom+Hydrogen 在虚拟环境中查找包裹