From the convolveND docs:

The kernel's origin is taken to be at the kernel's center. If your kernel has a dimension of even order then the origin's coordinates get rounded up to the next higher pixel (e.g. (1,2) for a 3x4 kernel). This mimics the behavior of the earlier convolve and fftconvolve routines, so convolveND is a drop-in replacement for them.

Maybe we need a para like that for conv1d?

(Mobile)


On Dec 29, 2009, at 8:15 PM, Chris Marshall <[email protected]> wrote:

Chris Marshall wrote:
Cliff Sobchuk wrote:
I am looking at the outputs that you provided, and they all look
incorrect to me. The convolution shouldn't be 0 for the first 5
elements, then element 6 = 2, element 7 = 0, element 8 = -1, element
9..11 = 0.

Comments? (btw, I am on vacation until Jan.4 so you might get an ooo
alert, but every couple of days I check my email.)

Try help conv1d to see the computation being performed.

In the perldl shell.

I just checked the calculation of the convolution again and
get the same result.  This result agrees (now) with conv2d
and convolutionND.

Meaning to say the current convention for the conv1d()
implementation is consistent with that of conv2d() and
convolveND().  The current implemention is not documented
as to how it kernels with even numbers of elements are
processed.

--Chris

What do you think the convolution of the $a and $b below
should be?

--Chris

Cliff Sobchuk esn 361-8169, 403-262-4010 ext: 361-8169
Fax: 403-262-4010 ext: 361-8170
Core RF Support Engineer

   "The author works for Telefonaktiebolaget L M Ericsson
("Ericsson"), who is solely responsible for this email and its contents.
All inquiries regarding this email should be addressed to Ericsson.
Nortel has provided the use of the nortel.com domain to Ericsson in
connection with this email solely for the purpose of connectivity and Nortel Networks has no liability for the email or its contents. The web
site for Ericsson is www.ericsson.com."


-----Original Message-----
From: Chris Marshall [mailto:[email protected]]
Sent: December 19, 2009 12:33 PM
To: [email protected]
Cc: perldl
Subject: [Perldl] conv1d or corr1d

I would like to fix the fftconvolve() bug for the PDL-2.4.6
release:

http://sourceforge.net/tracker/?func=detail&aid=2630369&group_id=612&ati
d=100612

but I'm having problems since it appears that our PDL conv1d() routine
actually calculated the 1D correlation of the arguments.

First set up simple arguments:

  perldl> $a = zeroes(11);
  perldl> $a(5) .= 1;
  perldl> p $a
  [0 0 0 0 0 1 0 0 0 0 0]

  perldl> $b = pdl(2,0,-1);
  perldl> p $b
  [2 0 -1]

The analytic convolution is calculated to be:

  perldl> $ctrue = $a->zeroes;
  perldl> $ctrue(4) .= 2;
  perldl> $ctrue(6) .= -1;
  perldl> p $ctrue
  [0 0 0 0 2 0 -1 0 0 0 0]

Here are the various PDL convolution outputs:

  perldl> p $c1d = conv1d $a, $b;     # wrong!
  [0 0 0 0 -1 0 2 0 0 0 0]

  perldl> use PDL::Image2D
  perldl> p $c2d = conv2d $a, $b;      # right!
  [
   [ 0  0  0  0  2  0 -1  0  0  0  0]
  ]

  perldl> use PDL::ImageND
  perldl> p $cNd = convolveND $a, $b;  # right!
  [0 0 0 0 2 0 -1 0 0 0 0]

The good news is that the conv2d() and convolveND() routines appear to
be calculating a convolution so the only "broken"
routine appears to be the conv1d(). My plan is to add a test for the
bug, fix the code/docs, and update the Release_Notes

--Chris


_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to