WNCC - Weighted Normalized Cross Correlation

버전 1.0.0.0 (4.14 KB) 작성자: Andrew Diamond
Performs pattern matching in an image via normalized cross correlation but with a weighted template
다운로드 수: 1.6K
업데이트 날짜: 2011/10/18

라이선스 보기

Normalized Cross Correlation (NCC) is an excellent choice for finding a given pattern in an image given a known scale and orientation. Matlab's IP toolbox normxcorr2 function does this.

However there's no way to specify which pixels of the pattern are important. This is particularly problematic because the template (i.e. pattern) matrix inadvertently specifies a rectangular ROI. So if the pattern as it appears in the image has artifacts close enough to the pattern, it will be in range of the template window and so the response will be degraded. Assuming that the nature of the problem is such that such artifacts are not actually important to the pattern match, being able to de-weight pixels away from the pattern can mitigate this.

Note: This function is more expensive than normxcorr2. It uses 3 convolutions (technically correlation) between image and template sized matrices. The convolution implementation automatically switches between frequency and spatial domains and so the time is usually “reasonable” .

The WNCC formula (but not the implementation) is the same as NCC but it with weighted variance vs regular variance, i.e.
NCC = cov(x,y)/sqrt(cov(x,x)*cov(y,y))
==>
WNCC = wcov(x,y,w)/sqrt(wcov(x,x,w)*wcov(y,y,w))
Where “wcov” is the weighted covariance w/r to the weights “w”
(see the comments in wncc for details)

In the example (picture) above, the “template” (i.e. pattern) is a cross. The “image” has such a pattern but within the rectangular region that contains it there are two bright artifacts that degrade the performance of NCC (bottom right). The “template weights” image shows that the WNCC matching will largely ignore anything not very close to a cross shaped ROI. In particular, this weighting will allow the artifacts to be ignored. The improved result (note colorbars) is shown in the WNCC image (bottom left).

Tested in 2008a, 2008b, 2008b, 2011a

인용 양식

Andrew Diamond (2025). WNCC - Weighted Normalized Cross Correlation (https://kr.mathworks.com/matlabcentral/fileexchange/33340-wncc-weighted-normalized-cross-correlation), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2008a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Template Matching에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0