繁体   English   中英

使用多个 X 和 Y 点裁剪图像 c#

[英]Crop Image with multiple X and Y points c#

我有需要裁剪的图像,并且有多个 X、Y 坐标来裁剪名片或纸张。 最好的方法是什么。

我的坐标如下。 X:490,y:0 X:1442,y:0 X:1442,y:4031 X:490,y:4031

在此处输入图片说明

您可以从Leadtools Image Processing Nuget查看KeyStoneCommand

这个 Nuget 包还包括一个检测文档 ip 命令,如果您不知道名片的边界框,您可以使用它来检测并返回名片的 4 个点。

这是一个代码片段:

private RasterImage DetectAndDeskew(RasterImage image)
{
   DetectDocumentCommand detectDocumentCommand = new DetectDocumentCommand();
   detectDocumentCommand.Run(image);

   if (detectDocumentCommand.DocumentArea == null)
   {
      Console.WriteLine("No document detected");
      return null;
   }

   KeyStoneCommand command = new KeyStoneCommand(detectDocumentCommand.DocumentArea);
   command.Run(image);

   image = command.TransformedImage;
   return image;
}

这是此过程的输出图像:

从代码输出图像

免责声明:我受雇于这个 nuget 的制造商

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM