trying to find 2D similarity patterns by xcorr2

From: lucy (losemind_at_yahoo.com)
Date: 12/21/04


Date: Tue, 21 Dec 2004 12:15:20 -0800

Hi all,

I am trying to find 2D similarity patterns in order to match two image
objects...

For simplicity, I want to ask this question in terms of 1D case:

Easy cases are zeros and non-zeros:

But I still don't know the relationship between the position of the peak of
XCORR result and the relative shifting of y that I should do in order to do
a matching...

I mean, I know I should shift "y" a little bit in order for the best
matching... but how much?

>> x=[0 0 0 1 1 1 0 0 0 0];
>> y=[0 0 0 0 0 0 1 1 1 1 0 0 0];
>> xcorr(x, y)

ans =

  Columns 1 through 7

    0.0000 0 -0.0000 -0.0000 0.0000 -0.0000 1.0000

  Columns 8 through 14

    2.0000 3.0000 3.0000 2.0000 1.0000 0.0000 -0.0000

  Columns 15 through 21

         0 -0.0000 0.0000 0 0.0000 0.0000 -0.0000

  Columns 22 through 25

    0.0000 -0.0000 0 -0.0000

>> x1=[1 1 1 0 0 0 0];
>> y

y =

  Columns 1 through 12

     0 0 0 0 0 0 1 1 1 1 0 0

  Column 13

     0

>> xcorr(x1, y)

ans =

  Columns 1 through 7

    0.0000 0.0000 0.0000 1.0000 2.0000 3.0000 3.0000

  Columns 8 through 14

    2.0000 1.0000 -0.0000 0.0000 0.0000 0.0000 0.0000

  Columns 15 through 21

   -0.0000 -0.0000 0.0000 -0.0000 -0.0000 -0.0000 -0.0000

  Columns 22 through 25

   -0.0000 0 0 -0.0000

>>

Now suppose the similar patterns are embedded in a noisy setting... the
following two vectors have similar patterns of 1 2 3 4 4 ...

How do I detect such a similar pattern? How to decide how many shifts should
my y2 have?

>> x=[1 0 1 1 2 3 4 4 1 0 1 0 1];
>> y2=[1 1 1 1 1 1 2 3 4 4 1 0 1 0 1];
>> xcorr(x, y2)

ans =

  Columns 1 through 7

    1.0000 0.0000 2.0000 1.0000 4.0000 8.0000 11.0000

  Columns 8 through 14

   15.0000 17.0000 23.0000 32.0000 42.0000 51.0000 43.0000

  Columns 15 through 21

   34.0000 26.0000 22.0000 22.0000 20.0000 16.0000 12.0000

  Columns 22 through 28

    7.0000 3.0000 2.0000 2.0000 1.0000 1.0000 0

  Column 29

    0.0000



Relevant Pages

  • Re: Is it just me, or is it cold in here?
    ... ne'mind shift them about into patterns on the ground. ... There are three strong fit adults in the cojjers establishment. ...
    (uk.rec.sheds)
  • Re: Speeding up an application - general rules
    ... I will also review those URLS. ... The file names and matching patterns are returned to the ... "find" command which is piped to sed to correct patterns that match ...
    (comp.lang.perl.misc)
  • Re: Greenspunning ML (revisited)
    ... to be embedded in individual branches where alternative patterns are ... Lisp with some kind of closed algebraic data types equivalent to ML's ... ML's pattern matching was designed to make it easy to convey ... statically-checked constraints. ...
    (comp.lang.lisp)
  • Re: Speeding up an application - general rules
    ... "find" command which is piped to sed to correct patterns that match ... The matching lines are then shoved into an array. ... Can I speed things by eliminating the sed command and letting Perl ...
    (comp.lang.perl.misc)
  • Re: Speeding up an application - general rules
    ... The file names and matching patterns are returned to the ... the script uses perl's system command to run a long winded ...
    (comp.lang.perl.misc)