简体   繁体   English

AForge.NET在两个图像中比较并查找Blob(连接的组件)

[英]AForge.NET Compare and find Blobs(Connected Components) in two images

I want to use AForge.NET library to examine similiar images and to localize the differences. 我想使用AForge.NET库检查相似的图像并定位差异。 I can imagine the following algorithm. 我可以想象以下算法。

a. 一种。 Compare 2 images, generate as result binary image with white pixels for differences and black pixels for matches. 比较2张图像,结果生成二进制图像,其中白色像素表示差异,黑色像素表示匹配。

b. b。 Use BlobCounter for searching of the connected pixels. 使用BlobCounter搜索连接的像素。

What filter can be used for a)? 什么过滤器可用于a)? How to count the pixels in each Blob ? 如何计算每个Blob中的像素?

Take a look at my previous answer here Aforge Blob Detection 在这里查看我以前的答案Aforge斑点检测

For A), you can use the ThresholdDifference, this will give you black pixels when there are no changes and white pixels when there is a difference. 对于A),您可以使用ThresholdDifference,这将在没有变化的情况下为您提供黑色像素,在有差异的情况下为您提供白色像素。 You can invert this with a Image>Invert ( http://www.aforgenet.com/framework/docs/html/458e1304-0858-ae29-113f-e2ec9072c626.htm ) 您可以使用Image> Invert( http://www.aforgenet.com/framework/docs/html/458e1304-0858-ae29-113f-e2ec9072c626.htm )将其反转

As for B), you can use Connected Component Labeling (see the post), this will give an approximate width and height of the objects. 对于B),您可以使用Connected Component Labeling(请参见文章),这将给出对象的大致宽度和高度。 If you want count exactly how many pixels are different you will probably need to write an procedure for this. 如果您想精确计算出多少像素不同,您可能需要为此编写一个过程。 It is not very difficult, it is just a two nested For cycle that will go over each X, Y pixel and then will increase a counter every time it finds an specific color on it. 这不是很困难,它只是两个嵌套的For循环,它将遍历每个X,Y像素,然后每次在其上找到特定颜色时都会增加一个计数器。

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

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