图像变换 [英] image transformations

查看:188
本文介绍了图像变换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在使用gnu-gsl和CImg来实现一些用于仿射和度量修正的基本投射空间技术。



我已经完成了计算仿射修正,但是,我很难弄清楚如何将仿射校正矩阵应用到原始(输入)图像。



我当前的思考过程是迭代在每个像素坐标的输入图像上。然后通过仿射校正矩阵乘以原始像素坐标(转换为齐次坐标)以获得输出像素坐标。



然后使用输出像素坐标访问输出图像并使用原始图像中的像素颜色对输出图像的像素位置进行混合(加法)操作。



听起来不错吗?在将原始像素坐标乘以仿射校正矩阵后,我得到了很多非常奇怪的值。

解决方案

不,你的价值观不应该是奇怪的。你为什么不做一个简单的例子,一个小规模的翻译;例如。

  x'= 1.01 * x + 0.0 * y + 5; 
y'= 0.0 * x + 0.98 * y + 10;

现在(10,10)处的像素应映射到(15.1,19.8),对吗? / p>

如果你想制作一个漂亮的输出图像,你应该找到前向投影然后再投影到输入图像并在那里进行插值而不是尝试融入输出图像。否则你最终会在输出中出现空白。



你需要在这里小心你的术语;听起来像你在做投影,有时在计算机图形社区中称为翘曲。整顿是另一回事,但这取决于你在做什么。


So I've been using gnu-gsl and CImg to implement some of the fundamental projective space techniques for affine and metric rectification.

I've completed computing an affine rectification but, I'm having a hard time figuring out how to apply the affine rectification matrix to the original (input) image.

My current thought process is to iterate across the input image for each pixel coordinate. Then multiply the original pixel coordinate (converted to a homogeneous coordinate) by the affine rectification matrix to get the output pixel coordinate.

Then access the output image using the output pixel coordinate and conduct a blend (addition) operation on the output image's pixel location with the pixel color from the original image.

Does that sound right? I'm getting a lot of really weird values after multiplying the original pixel coordinate by the affine rectification matrix.

解决方案

No, your values should not be weird. Why don't you make a simple example, a small scale with a small translation; e.g.

x' = 1.01*x + 0.0*y + 5;
y' = 0.0*x + 0.98*y + 10;

Now the pixel at (10,10) should map to (15.1,19.8), right ?

If you want to make a nice output image, you should find the forward projection and then back project to the input image and interpolate there rather than try to blend into the output image. Otherwise you will end up with gaps in the output.

You need to be careful with your terminology here; it sounds to me like you are doing projections, sometimes called warping in the computer graphics community. Rectification is something else, but it depends on what you are doing.

这篇关于图像变换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆