将图像映射到一组坐标上 [英] Mapping an image onto a set of coordinates

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

问题描述

我有一个3:4宽高比的典型源图像。我还有一组坐标,我需要将图像映射到单独的图像中。坐标不是完美的矩形;如果有的话,他们定义一个不规则的网格。

I have a typical source image with a 3:4 aspect ratio. I also have a set of coordinates that I need to map the image onto in a separate image. The coordinates are not perfectly rectangular; if anything they define an irregular mesh.

例如,(0,0)可能映射到(12,33),(120,0)=>(127 ,36),(240,0)=>(226,13)等。

So for example, (0,0) might map to (12,33), (120,0) => (127,36), (240,0)=>(226,13), etc.

我的目标是通过映射使我的源图像适合新的形状源坐标到目的地并应用失真。

My goal is to get my source image to fit onto the new shape by mapping the source coordinates to the destination and applying distortion.

有哪些方法可以实现这一目标?我正在使用.NET,但很好的呼吁,例如ImageMagick。

What are some ways to accomplish this? I'm using .NET but am fine calling out to e.g. ImageMagick.

编辑:根据要求,这是一张图片。左图是一张简单的照片,均匀细分(忽略我糟糕的MSPaint技能)。右侧显示目标形状。我有右侧每个点的坐标。目标是将平面图像映射(投影?)到形状上,使点对齐。

As requested, here's a picture. The left image is a simple photo, evenly subdivided (ignore my crappy MSPaint skills). The right side shows the target shape. I have coordinates for each dot on the right side. The goal is to map (project?) the flat image onto the shape so that the dots line up.

推荐答案

我有一些扭曲算子的例子在我的网站上( http://www.rubblewebs.co.uk/imagemagick/ operator / distort.php ) - 使用php但你会得到这个想法。

I have some examples of the distort operators on my site ( http://www.rubblewebs.co.uk/imagemagick/operators/distort.php ) - using php but you will get the idea.

你可能想要shepards方法。

You probably want the shepards method.

$cmd = "$input -matte -virtual-pixel transparent".  
" -distort Shepards \"0,0 0,0  0,100 20,100 0,200".  
" 0,200 133,200 133,180 266,200 266,200 266,100".  
" 246,100 266,0 266,0 133,0 133,20\" ";  
exec("convert $cmd shepards.png");

这篇关于将图像映射到一组坐标上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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