c# - 使用 emgucv 测量两个图像的差异

标签 c# image-processing compare emgucv

我需要比较两张图片并确定它们的差异百分比。 emgucv 上的“Absdiff”功能对此没有帮助。我已经在 emgucv wiki 上完成了那个比较示例。我真正想要的是如何以数字格式获得两个图像差异?

//emgucv wiki compare example

//acquire the frame
Frame = capture.RetrieveBgrFrame(); //aquire a frame
 Difference = Previous_Frame.AbsDiff(Frame);
//what i want is
double differenceValue=Previous_Frame."SOMETHING";

如果您需要更多详细信息,请询问。 提前致谢。

最佳答案

基于 EmguCV MatchTemplate 的比较

Bitmap inputMap = //bitmap  source image
Image<Gray, Byte> sourceImage = new Image<Gray, Byte>(inputMap);

Bitmap tempBitmap = //Bitmap template image
Image<Gray, Byte> templateImage = new Image<Gray, Byte>(tempBitmap);

Image<Gray, float> resultImage = sourceImage.MatchTemplate(templateImage, Emgu.CV.CvEnum.TemplateMatchingType.CcoeffNormed);

double[] minValues, maxValues;
Point[] minLocations, maxLocations;
resultImage.MinMax(out minValues, out maxValues, out minLocations, out maxLocations);

double percentage = maxValues[0] * 100; //this will be percentage of difference of two images

两个图像需要具有相同的宽度和高度,否则 MatchTemplate 将抛出异常。如果我们想要完全匹配。 或者 模板图像应小于源图像以获得模板图像在源图像上的出现次数

关于c# - 使用 emgucv 测量两个图像的差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17001324/

相关文章:

c# - 将多个 Api 调用建模为 1 个对象(数据结构)

ios - 架构 armv7 的 undefined symbol : "_objc_readClassPair", 引用自 : __ARCLite__load() in libarclite_iphoneos. a(arclite.o)

java - 实现可比接口(interface)

c# - 如何使用包含多个工作表的 OOXML SDK 创建新的电子表格文件?

C#后台 worker 更新状态标签

c# - .NET 中的值类型、不变性(好的)和可变性(坏的)

c - 在 C 中实现 imagesc

python - pytesseract,Windows 错误 : [Error 2] The system cannot find the file specified

c# - 如何高效地逐项比较两个大的 XML 文件?

python - 字典中两个列表结果的比较具有重复的项目