C# 和 Aforge - 从 blob 中提取图像
以下函数解决了问题,但我不明白如何调用它,特别是“out List ImgLetters”部分。
public static bool ApplyBlobExtractor (Bitmap SourceImg, int LettersCount, out List<Bitmap> ImgLetters)
{
ImgLetters = null;
ImgLetters = new List<Bitmap> ();
BlobCounter blobCounter = new BlobCounter ();
// Sort order
blobCounter.ObjectsOrder = ObjectsOrder.XY;
blobCounter.ProcessImage (SourceImg);
Blob[] blobs = blobCounter.GetObjects (SourceImg, false);
// Adding images into the image list
UnmanagedImage currentImg;
foreach (Blob blob in blobs)
{
currentImg = blob.Image;
ImgLetters.Add (currentImg.ToManagedImage ());
}
return ImgLetters.Count == LettersCount;
}
现在让我们看一下:
public static bool ApplyBlobExtractor (Bitmap SourceImg, int LettersCount, out List<Bitmap> ImgLetters)
Bitmap SourceImg - 图片,其中将找到 blob
int LettersCount - 我们要提取的 blob(数字)
列表 ImgLetters< /强> - ???
第三个参数有什么作用(如何调用这个函数)?
Bitmap image1 = new Bitmap(@"C:\1.png");
..
ApplyBlobExtractor (image1, 1, ??? )
..
image2.save(@"C:\2.png")
Following function solves the problem, but I don't understand how to call it, especially "out List ImgLetters" part.
public static bool ApplyBlobExtractor (Bitmap SourceImg, int LettersCount, out List<Bitmap> ImgLetters)
{
ImgLetters = null;
ImgLetters = new List<Bitmap> ();
BlobCounter blobCounter = new BlobCounter ();
// Sort order
blobCounter.ObjectsOrder = ObjectsOrder.XY;
blobCounter.ProcessImage (SourceImg);
Blob[] blobs = blobCounter.GetObjects (SourceImg, false);
// Adding images into the image list
UnmanagedImage currentImg;
foreach (Blob blob in blobs)
{
currentImg = blob.Image;
ImgLetters.Add (currentImg.ToManagedImage ());
}
return ImgLetters.Count == LettersCount;
}
Now lets look at this:
public static bool ApplyBlobExtractor (Bitmap SourceImg, int LettersCount, out List<Bitmap> ImgLetters)
Bitmap SourceImg - picture, where blobs will be found
int LettersCount - blob that we are going to extract (number)
out List ImgLetters - ???
What does 3rd parameter do (how to call this function)?
Bitmap image1 = new Bitmap(@"C:\1.png");
..
ApplyBlobExtractor (image1, 1, ??? )
..
image2.save(@"C:\2.png")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
out
参数允许您从方法调用中获取结果,而不是通过返回参数。 http://msdn.microsoft.com/en -us/library/t3c3bfhx(v=vs.80).aspx在您的示例中,方法
ApplyBlobExtractor
似乎需要一个源 Bitmap 和 LetterCount(大概是您期望找到的字母数),然后使用此 Blobcounter 对象将其切碎。如果它找到的字母数量与您期望找到的字母数量相同,它将返回 true。它还将通过 out 参数以列表形式为您提供输出图像。调用它会做类似的事情...
an
out
parameter allows you to get results back from a method call other than through the return parameter. http://msdn.microsoft.com/en-us/library/t3c3bfhx(v=vs.80).aspxIn your example the method
ApplyBlobExtractor
it appears to take a source Bitmap, and a LetterCount (presumably the number of letters you expect to find) it then uses this Blobcounter object to chop it up. It will return true if it finds the same number of letter you expect to find. It will also provide you the output images as a list back through the out parameter.to call it would would do something like...