Sum of absolute differences

In digital image processing, the sum of absolute differences (SAD) is an algorithm for measuring the similarity between image blocks. It works by taking the absolute difference between each pixel in the original block and the corresponding pixel in the block being used for comparison. These differences are summed to create a simple metric of block similarity, the L1 norm of the difference image or Manhattan distance between two image blocks.

The sum of absolute differences may be used for a variety of purposes, such as object recognition, the generation of disparity maps for stereo images, and motion estimation for video compression.

Contents

[hide]

Example[edit]

This example uses the sum of absolute differences to identify which part of a search image is most similar to a template image. In this example, the template image is 3 by 3 pixels in size, while the search image is 3 by 5 pixels in size. Each pixel is represented by a single integer from 0 to 9.

Template    Search image
 2 5 5       2 7 5 8 6
 4 0 7       1 7 4 2 7
 7 5 9       8 4 6 8 5

There are exactly three unique locations within the search image where the template may fit: the left side of the image, the center of the image, and the right side of the image. To calculate the SAD values, the absolute value of the difference between each corresponding pair of pixels is used: the difference between 2 and 2 is 0, 4 and 1 is 3, 7 and 8 is 1, and so forth.

Calculating the values of the absolute differences for each pixel, for the three possible template locations, gives the following:

Left    Center   Right
0 2 0   5 0 3    3 3 1
3 7 3   3 4 5    0 2 0
1 1 3   3 1 1    1 3 4

For each of these three image patches, the 9 absolute differences are added together, giving SAD values of 20, 25, and 17, respectively. From these SAD values, it could be asserted that the right side of the search image is the most similar to the template image, because it has the lowest sum of absolute differences as compared to the other two locations.

Comparison to other metrics[edit]

Object recognition[edit]

The sum of absolute differences provides a simple way to automate the searching for objects inside an image, but may be unreliable due to the effects of contextual factors such as changes in lighting, color, viewing direction, size, or shape. The SAD may be used in conjunction with other object recognition methods, such as edge detection, to improve the reliability of results.

Video compression[edit]

SAD is an extremely fast metric due to its simplicity; it is effectively the simplest possible metric that takes into account every pixel in a block. Therefore it is very effective for a wide motion search of many different blocks. SAD is also easily parallelizable since it analyzes each pixel separately, making it easily implementable with such instructions as MMX and SSE2. For example, SSE has packed sum of absolute differences instruction (PSADBW) specifically for this purpose. Once candidate blocks are found, the final refinement of the motion estimation process is often done with other slower but more accurate metrics, which better take into account human perception. These include the sum of absolute transformed differences (SATD), the sum of squared differences (SSD), and rate-distortion optimization.

时间: 2024-12-30 04:00:01

Sum of absolute differences的相关文章

ffmpeg最全的命令参数

Hyper fast Audio and Video encoderusage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... Getting help: -h -- print basic options -h long -- print more options -h full -- print all options (including all format and code

基于灰度的模板匹配算法(一):MAD、SAD、SSD、MSD、NCC、SSDA算法

简介: 本文主要介绍几种基于灰度的图像匹配算法:平均绝对差算法(MAD).绝对误差和算法(SAD).误差平方和算法(SSD).平均误差平方和算法(MSD).归一化积相关算法(NCC).序贯相似性算法(SSDA).下面依次对其进行讲解. MAD算法 介绍 平均绝对差算法(Mean Absolute Differences,简称MAD算法),它是Leese在1971年提出的一种匹配算法.是模式识别中常用方法,该算法的思想简单,具有较高的匹配精度和较少的计算量,广泛用于图像匹配. 设S(x,y)是大小

查看FFMPEG的全部帮助内容

ffmpeg -h full Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... Getting help: -h -- print basic options -h long -- print more options -h full -- print all options (including all

Correlation based similarity measures-Summary

Correlation based matching typically produces dense depth maps by calculating the disparity at each pixel within a neighborhood. This is achieved by taking a square window of certain size around the pixel of interest in the reference image and findin

kmeans 初步学习小结

接触kmeans 算法比较长时间了,但是一直没好好明白怎么回事.推荐几个好点的链接. http://coolshell.cn/articles/7779.html http://blog.csdn.net/zouxy09/article/details/9982495 http://www.360doc.com/content/13/1122/14/10724725_331295214.shtml 运用matlab函数的一个最基本程序 yangben= load('F:\iris.txt');

AVS AVL 模板匹配

https://docs.adaptive-vision.com/current/studio/machine_vision_guide/TemplateMatching.html 模板匹配 Template Matching 简单模板匹配 Naive Template Matching 基本原理 NCC(Normalized Cross-Correlation) 模板图像和输入图片匹配的结果也是一种图像 Template Correlation Image. 2.1 两种方法, 找出相关性最大

COMP 9517

COMP 9517T1, 2020 Assignment 1: SpecificationMaximum marks achievable: 10 marksThis assignment is worth 10% of the total course marks.Deliverables: You will submit a report (maximum 5 pages) briefly explaining the approach youhave taken in Tasks 1, 2

Clustering by Passing Messages Between Data Points(Brendan J.Frey* and Delbert Dueck)例子

例1,数据点聚类:AP应用到25个二维数据中,使用负平法误差作为相似度  聚类数目不用预先指定 AP的一个优点是聚类数目不用预先指定,而是在消息传递方法中慢慢浮现,取决于输入参考度(preference),这种自动模型的选择,基于先验指定每一个数据点有多合适作为exemplar. 下图表示输入常量参考度对聚类数目的影响,这种关系近乎同样于在精确最小平方误差中的关系. 例2,人脸识别:使用优化标准为均方差,识别900张灰度图像   AP一致的能够实现更低的误差,在时间上花费要少于两个数量级. AP

Computer Graphics Research Software

Helping you avoid re-inventing the wheel since 2009! Last updated December 5, 2012.Try searching this page for keywords like 'segmentation' or 'PLY'.If you would like to contribute links, please e-mail them to [email protected]. Papers & Archives Gra