如何将二维环表面的点映射到矩形
我的问题是我有一条线(左侧红色),我想对其进行转换以得到如右图所示的内容。 (这是一个二值化图像,所以一切都是黑色的,除了这里的(红色)线,它在图片上是白色的。)黑点象征着灰色圆圈的中心。所以很明显,红线的点不能适合1个圆的边缘,但存在2个具有r1,r2(半径)的圆,它们一起创建一个环,其表面(图中的灰色)可以包含所有红线的点。对于不同的图片,r1和r2可以不同,但保证r2>r1>0。
所以我需要一个映射,它可以将红线的点(x,y)(numpy矩阵)从灰色环转换为矩形。 “没有公式”我会想象这就像在环的某处切割,然后将其折叠成矩形。
My problem is that I have a line (red on the left), and I want to transform it to get something like on the right picture. (This is a binarized image, so everything is black, except the (red) line here which is white on the picture.) The black dot simbolizes the center of the gray circle. So it is obvious, that the points of the red line can not fit to the edge of 1 circle, but exist 2 circles with r1, r2 (radius) which together create a ring and its surface(gray on the picture) can contain all of the points of the red line. For different pictures r1 and r2 can be different, but it is guaranteed that r2>r1>0.
So I need a mapping, which can transform the points(x,y) (numpy matrix) of the red line from the gray ring to a rectangle.
"Without formulas" I would imagine this like cutting somewhere the ring, and folding it into a rectangle.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如@fmw42 敏锐指出的,您可以使用
cv2.warpPolar
。这是一个例子。输入:so71416458-crop.png
这里明显的“摆动”是我草率裁剪的结果 - 环的中心点并不完全位于图像的中点。
输出:so71416458-straight.png
As astutely pointed out by @fmw42, you can use
cv2.warpPolar
. Here's an example.input: so71416458-crop.png
The "wobble" evident in here is a result of my sloppy cropping – the center point of the ring isn't exactly at the midpoint of the image.
output: so71416458-straight.png