2014-12-02 23 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; 
}