2014-12-02 22 views
1

我想写一些将接受2个图像的东西,并将返回一个数组(或某种集合),并且每个元素表示图像之间的差异。AForge.net - BlobCounter获取2个图像之间的不同“区域”

例如,如果我在源图像中有一张背景和一个站在右侧的男子的照片,并且与同一张照片不同,但与第一张照片的区别在于该男子站在左侧比我会有一个1的集合返回给我的XY坐标,其中变化开始和变化的宽度和高度。

我发现AForge有一个BlobCounter类用于这样的目的,但不能完全理解我应该给它 - 在例子中(http://www.aforgenet.com/framework/docs/html/d7d5c028-7a23-e27d-ffd0-5df57cbd31a6.htm)在文档中我看到只处理一个图像 - 但不是比较。我找不到更好的例子。

我在这里错过了什么(我是图像处理新手)。

回答

1

找到了解决办法感谢这里一个帖子:Aforge Blob Detection随着BlobCounters

这里是我的解决方案:

// create filter 
ThresholdedDifference filter = new ThresholdedDifference(60); 
// apply the filter 
filter.OverlayImage = currentImg; 
Bitmap resultImage = filter.Apply(_lastImg); 

// create an instance of blob counter algorithm 
BlobCounter bc = new BlobCounter(); 
// process binary image 
bc.ProcessImage(resultImage); 
Rectangle[] rects = bc.GetObjectsRectangles(); 
// process blobs 
foreach (Rectangle rect in rects) 
{ 
    string a = String.Empty; 
}