问题描述
我不知道这是否应该在数学论坛或编程论坛中使用,但我会在两者中均张贴并查看我的去向.
I dunno if this should go in a Math forum or a Programming forums, but I'll post it in both and see where I get.
我有两个计算机图像...其中一个是原始"图像(大的TIF文件).另一个是原始图像的变形版本……它已在软件程序中旋转,剪切和翻译.我需要对转换后的图像进行一些处理,但是我需要原始图像中每个像素的(x-y)坐标才能完成计算.
I have two computer images... one of them is an "original" image (a large TIF file). The other one is a transformed version of the original image... it's been rotated, sheared and translated in a software program. I need to do some work on the transformed image, but I need the (x-y) coordinates of each pixel in the original image to finish my calculations.
我知道图像是用3x3转换矩阵旋转和剪切的.如果我有矩阵,则可以从第一个图像(反之亦然)中得出第二个图像.我不知道它被旋转,剪切或平移了多少,所以我不能仅仅从一组已知的变换中得出矩阵.我所拥有的是每个图像中的一组对应点(角等)及其对应的(x,y)坐标.所以这是我的两难境地:
I know that the image was rotated and sheared with a 3x3 Transformation matrix. If I had the matrix, I could derive the second image from the first (or vice-versa) myself. I don't know exactly how much it was rotated, sheared, or translated, so I can't just derive the matrices from a set of known transformations. What I do have is a set of corresponding points (the corners, et al) in each image, and their corresponding (x,y) coordinates. So here's my dilemma:
使用一组对应的变换点((x,y)->(x',y'),其中三个或更多),可以导出用于将一个图像转换为另一个图像的转换矩阵吗?如果可以导出矩阵,则可以求解所有像素(所有1800万个'em)的原始坐标,并完成需要做的计算.
Using a set of corresponding transformed points ((x,y) -> (x',y'), three or more of them), can I derive the Transformation matrix that was used to turn one image into the other? If I can derive the matrix, I can solve for the original coordinates of all the pixels (all 18-million of 'em) and get the calculations done that I need to do.
任何人都可以帮忙吗?我对线性代数很熟悉...只是不足够熟悉而无法完全理解.任何事情都值得赞赏!
Can anyone help? I'm familiar with linear algebra... just not familiar enough to derive this without a whole lotta head scratching. Anything is appreciated!
- 迈克
推荐答案
不确定是手动还是自动 ...
Not sure if you want manual or automatic...
手册
如果指定矩形四个角的变换坐标,则可以导出变换方程:
If you specify the transformed coordinates of the four corners of your rectangle, then you can derive the transformation equations:
替代文字http://www.praeclarum.org/so/wellner.png
(摘自Pierre Wellner的与DigitalDesk上的纸进行交互以及他的论文中的更多详细信息>)
(From Pierre Wellner's Interacting with Paper on the DigitalDesk and more details in his Thesis)
现在您只需要求解方程的系数即可.
Now you just have to solve for the coefficients of the equation.
最后,您可以将这些方程式转换为所需的3x3矩阵.上面的方程式足够强大,可以进行非线性变换,您可以将其简化为3x3仿射剪切矩阵.
Lastly, you can turn those equations into the 3x3 matrices you want. The above equations are powerful enough to do non-linear transformations and you can simplify it into the 3x3 affine shear matrix.
但是我会坚持使用非线性方程(上面),因为它们可以处理透视变形.
自动
相同的方法,但是您可以将边缘检测器与线检测算法结合使用,以找到组成矩形的一组4色线.
Same method, but you can use an edge-detector comboined with a line detection algorithm to find a set of 4-ish lines that makeup a rectangle.
如果您的图像矩形确实很突出(深色背景上的白色图像),则可以使用角落检测,该库可从 OpenCV的功能检测(请参见cvCornerHarris
).
If your image rectangles really stand out (whiteish images on a dark background), then you can use corner detection available from libraries like OpenCV's Feature Detection (see cvCornerHarris
).
您可以将这些线相交以找到四个角并使用变换方程.
You can intersect those lines to find the four corners and use the transformation equation.
这篇关于尝试仅使用图像导出2D变换矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!