我正在研究一个关于图像处理的项目,我目前正在研究与模板匹配有关的子系统,并且我正在实施 SAD 技术(绝对差异之和)以找到多个图像之间的匹配. 我已经实现了代码并且工作正常。我的问题是关于我正在使用的 minSAD 值。它被预定义为 100000 的值。我理解它的方式是 minSAD 越低,我们找到的匹配就越准确。我只需要在搜索时找到更多关于它的信息,似乎没有什么可以详细描述它。只需要这个解释来更好地理解它,所以任何帮助都将不胜感激。
minSAD = VALUE_MAX;
// loop through the search image
for ( int x = 0; x <= S_rows - T_rows; x++ ) {
for ( int y = 0; y <= S_cols - T_cols; y++ ) {
SAD = 0.0;
// loop through the template image
for ( int j = 0; j < T_cols; j++ )
for ( int i = 0; i < T_rows; i++ ) {
pixel p_SearchIMG = S[x+i][y+j];
pixel p_TemplateIMG = T[i][j];
SAD += abs( p_SearchIMG.Grey - p_TemplateIMG.Grey );
}
// save the best found position
if ( minSAD > SAD ) {
minSAD = SAD;
// give me min SAD
position.bestRow = x;
position.bestCol = y;
position.bestSAD = SAD;
}
}
}