我需要比较两张图片并确定它们的差异百分比。 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/