平方差和算法如何工作? [英] How does sum of squared difference algorithm work?

查看:110
本文介绍了平方差和算法如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个图像a和b,其中b是图像a的块。我想使用块匹配找到b。我该怎么办?

I have a two images a and b, where b is a block of image a. I want to find b using block matching. How do I go about it?

推荐答案

这很简单,实际上名称告诉您几乎所有您需要了解的内容-您只需计算每个像素的平方差值之和即可。

It's very simple, in fact the name tells you pretty much everything you need to know - you just calculate the sum of the squared difference value for each pixel.

要计算两个图像的SSD:

To calculate the SSD for two images:

ssd = 0
for i = 0 to height - 1
    for j = 0 to width - 1
        diff = A[i][j] - B[i][j]
        ssd += diff * diff

通常的想法是,用于匹配图像的SSD会很小。如果要匹配两个图像,其中一个图像被平移了一定数量,那么通常会采用蛮力方法,即在x,y位移范围内计算SSD,然后确定最小SSD值,即然后应对应于最佳对齐偏移。

The general idea is that for matching images the SSD will be small. If you're trying to match two images, where one image is translated by some amount, then you would typically do a brute force approach where you calculate the SSD over a range of x, y displacements and then identify the minimum SSD value, which should then correspond to the best alignment offset.

请注意,通常仅由于SSD的简单性和相对较低的计算成本而使用SSD-通常,使用< a href = https://en.wikipedia.org/wiki/Cross-correlation#Normalized_cross-correlation rel = noreferrer>标准化互相关。

Note that SSD is generally only used due to its simplicity and relatively low computational cost - in general you will get better results using Normalized Cross Correlation.

这篇关于平方差和算法如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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