help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Normalisation


From: Hartmut
Subject: Re: Normalisation
Date: Mon, 28 Aug 2017 10:35:36 -0700 (MST)

Welcome to Octave!

Please have a look here [1] where this question of your Udacity course has
been answered previously.

Short summary:

Your Udacity course works with an old version of Octave's image package.
Those results where buggy, and have now been (mostly) corrected.

Try this Octave code:

clear
pkg load image                        % using image 2.6.1 release
s = [-1 0 0 1 1 1 0 -1 -1 0 1 0 0 -1]
t = [1 1 0]
x = normxcorr2(t,s);
x(~isfinite(x))=0                       % to fix inf values (bug 50151)
[maxVal maxRawIndex] = max(x)

The resulting output is (slightly rounded):
x = 1 -0.5 -0.5 -1 -0.5 0 1 0.87 0.5 -1 -0.87 0.5 0.5 1 -0.5 -0.5
maxVal = 1
maxRawIndex = 7

The maxRawIndex could equally well be 1 or 14 instead of this 7. Those are
all the positions where x has the value 1 (the position 7 seems to be
closest to 1 because of machine precision).

The index 7 position corresponds to "1 1 0" in s, and the index 14 position
corresponds to "0 0 -1" in s. Both have the same maximum normalized cross
correlation to t. The index position 1 is just an artifact of padding the
borders (those padded borders are also currently not perfectly Matlab
compatible).

This raw index can the be transferred to the index in the original array s
if you like. You might do something like "index = rawIndex-(length(t)-1)/2".
Then you will get the center element in s that corresponds to your matching
substring. This value would then be 6 and would properly correspond to the
part "1 1 0" in s. 

Have fun with Octave and the image package

    Hartmut

[1]
http://octave.1599824.n4.nabble.com/Octave-4-0-3-normxcorr2-producing-unexpected-result-td4681543.html



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Normalisation-tp4682870p4684700.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]