[英]Perspective Image Transformation with tiling
On the hunt of a good image processing library which can be used for a new application I plan to create. 寻找一个好的图像处理库,可以用于我计划创建的新应用程序。 I will be using C#.NET (VS 2008)
我将使用C#.NET(VS 2008)
My application needs to do the following: 我的应用程序需要执行以下操作:
Not just that, I need the final output image to be of a specified size. 不仅如此,我还需要最终输出图像具有指定的大小。 I want the application to be able to use the same perspective and return an image of the specified rectangular size (not the size of 4 points) I specify.
我希望应用程序能够使用相同的透视图并返回指定的矩形大小(不是4点的大小)的图像。 I hope you understand what I mean.
我希望你明白我的意思。 The source image needs to be tiled and transformed to produce an output that fits the specified area completely.
需要平铺和转换源图像以生成完全适合指定区域的输出。
I tried some libraries like Aforge.NET, ImageMagick, EMGU etc. Some are slow. 我尝试了一些像Aforge.NET,ImageMagick,EMGU等的库。有些库很慢。 Some can only produce a perspective image of small size.
有些只能生成小尺寸的透视图像。 Some give memory errors.
有些会给出内存错误。 Can't find a proper solution.
找不到合适的解决方案。
我认为这里的问题的答案对你的情况也有帮助。
You may want to take a look at this, as it may solve a portion of your problem, or lead you in the right direction: http://www.codeproject.com/KB/graphics/YLScsFreeTransform.aspx 你可能想看看这个,因为它可以解决你的问题的一部分,或引导你朝着正确的方向: http : //www.codeproject.com/KB/graphics/YLScsFreeTransform.aspx
It will take an image and distort it using 4 X/Y coordinates you provide. 它会拍摄一张图像并使用您提供的4个X / Y坐标对其进行扭曲。
Fast, free, simple code. 快速,免费,简单的代码。 Tested and it works beautifully.
经过测试,效果很好。 Simply download the code from the link, then use FreeTransform.cs like this:
只需从链接下载代码,然后使用FreeTransform.cs,如下所示:
using (System.Drawing.Bitmap sourceImg = new System.Drawing.Bitmap(@"c:\image.jpg"))
{
YLScsDrawing.Imaging.Filters.FreeTransform filter = new YLScsDrawing.Imaging.Filters.FreeTransform();
filter.Bitmap = sourceImg;
// assign FourCorners (the four X/Y coords) of the new perspective shape
filter.FourCorners = new System.Drawing.PointF[] { new System.Drawing.PointF(0, 0), new System.Drawing.PointF(300, 50), new System.Drawing.PointF(300, 411), new System.Drawing.PointF(0, 461)};
filter.IsBilinearInterpolation = true; // optional for higher quality
using (System.Drawing.Bitmap perspectiveImg = filter.Bitmap)
{
// perspectiveImg contains your completed image. save the image or do whatever.
}
}
FYI, I believe that .NET has a 2gb object memory limit, so if you're working with really large images, you may run into a memory error. 仅供参考,我相信.NET有2GB的对象内存限制,所以如果你正在处理非常大的图像,你可能会遇到内存错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.