且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从图像中删除空格周围

更新时间:2023-12-05 15:44:58

我已经写了code这样做自己 - 这不是太难以得到基本去。

I've written code to do this myself - it's not too difficult to get the basics going.

从本质上讲,你需要扫描像素行/列检查非白色像素和隔离产品形象的边界,然后创建一个新的位图只有该区域。

Essentially, you need to scan pixel rows/columns to check for non-white pixels and isolate the bounds of the product image, then create a new bitmap with just that region.

请注意,虽然 Bitmap.GetPixel()方法的工作,这是比较慢的。如果处理时间是非常重要的,你需要使用 Bitmap.LockBits()锁定内存中的位图,然后一个不安全{} 块直接访问像素。

Note that while the Bitmap.GetPixel() method works, it's relatively slow. If processing time is important, you'll need to use Bitmap.LockBits() to lock the bitmap in memory, and then some simple pointer use inside an unsafe { } block to access the pixels directly.

在$ C $的CProject本文给出了一些细节,你可能会发现有用的。

This article on CodeProject gives some more details that you'll probably find useful.