标准化scipy.ndimage.filters.correlate [英] Normalize scipy.ndimage.filters.correlate

查看:556
本文介绍了标准化scipy.ndimage.filters.correlate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何规范

scipy.ndimage.filters.correlate

获取功能:

XCM = 1/N(xc(a-mu_a,b-mu_b)/(sig_a*sig_b))

什么是相关的N?它通常是图像的数据点数/像素数. 我应该为scipy.ndimage.filters.correlate选择哪个值? 我的图像尺寸不同.我猜想scipy相关函数会将小图像填充为零吗?

最终矩阵的大小 N = XCM.sizeX() * XCM.sizeY() ?

谢谢,

解决方案

在我看来,您正在尝试计算两个图像的归一化互相关(我怀疑您可能正在尝试进行模板匹配?) .该答案假定归一化互相关就是您想要的.

  • 在计算两个图像之间的归一化互相关时,等于在模板和参考图像重叠的区域中减去均值并除以标准差. /p>

  • 在这里, N 等于模板中的像素数,这与模板和参考图像之间重叠的局部区域中的像素数相同当您将模板滑到参考上时.

  • 您应该阅读 Wikipedia关于互相关的文章,尤其是 Lewis(1995)的这篇文章有更深入的解释,并描述了有效地计算归一化互相关的一些巧妙技巧.

  • 我还编写了自己的用于模板匹配的Python函数,包括基于Lewis和MATLAB的一些片段的归一化互相关.您可以在此处找到源.

如果您还有其他问题,请告诉我.

does anybody have an idea how to normalize the

scipy.ndimage.filters.correlate

function to get :

XCM = 1/N(xc(a-mu_a,b-mu_b)/(sig_a*sig_b))

What is N for the correlation? It usually is the # of datapoints / pixels for images. Which value shall I choose for scipy.ndimage.filters.correlate? My images differ in size. I guess the scipy correlate function pads the small image into zeros?

The size of the final matrix N = XCM.sizeX() * XCM.sizeY() ?

Thanks, El

解决方案

It looks to me like you're trying to compute the normalized cross-correlation of two images (I suspect you're probably trying to do template matching?). This answer assumes that the normalized cross-correlation is what you want.

  • When you compute the normalized cross-correlation between your two images, you're doing the equivalent of subtracting the mean and dividing by the standard deviation to both your template and reference image in the region where they overlap.

  • Here, N would be equal to the number of pixels in your template, which is the same as the number of pixels in the local region of overlap between the template and the reference image as you slide the template over the reference.

  • You should read the Wikipedia article on cross-correlation, and in particular this bit for the definition of normalized cross-correlation and some explanation for what each of the terms mean.

  • This article by Lewis (1995) has a more in-depth explanation, and also describes some neat tricks for efficiently computing the normalized cross-correlation.

  • I also wrote my own Python functions for template matching including normalized cross-correlation based on Lewis and some snippets of MATLAB. You can find the source here.

Let me know if you have more questions and I'll have a go at explaining.

这篇关于标准化scipy.ndimage.filters.correlate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆