[Numpy-discussion] Convolve returning zero array

R.Jager at mapperlithography.com R.Jager at mapperlithography.com
Tue Dec 16 01:34:03 CST 2003


OK, here is the example:
[code]

from numarray import *
import numarray.convolve as conv

lx=20
center=10
index=arange(lx,type='Float64')
data1=(abs(center-index))<3
print 'The binary pattern:'
print data1

PSF=5
xwidth=18
xmid=xwidth/2
sigma=PSF/(sqrt(8*log(2)))
index=arange(xwidth,type='Float64')
ShortGauss = (1/(sqrt(2*pi)*sigma)) *
exp(-0.5*((index-xmid)/sigma)*((index-xmid)/sigma))
print '\nThe short gauss:'
print ShortGauss

image=conv.convolve(data1,ShortGauss,mode=conv.SAME)
print '\nThe convolution of the binary pattern with the short gauss:'
print image

PSF=5
xwidth=22
xmid=xwidth/2
sigma=PSF/(sqrt(8*log(2)))
index=arange(xwidth,type='Float64')
LongGauss = (1/(sqrt(2*pi)*sigma)) *
exp(-0.5*((index-xmid)/sigma)*((index-xmid)/sigma))
print '\nThe long gauss:'
print LongGauss

image=conv.convolve(data1,LongGauss,mode=conv.SAME)
print '\nThe convolution of the binary pattern with the long gauss:'
print image

[\code]

When I run this code, the first convolution gives an array of zeros, the
second convolution is good.

I also did a quick try with convolve from nd_image, but this function was
slower than the convolve from numarray with a large Gaussian distribution.

Remco Jager

MAPPER Lithography
Lorentzweg 1
2628 CJ Delft, The Netherlands
tel.: +31 (0)15 2789439
fax: +31 (0)15-2789473
http://www.mapperlithography.com

This e-mail, attachments and (any part of) its content are (i) intended for
the named addressee(s) only and (ii) strictly confidential and proprietary.
All rights are reserved by MAPPER Lithography. Any unauthorized use,
disclosure and/or copying are strictly prohibited, except with prior and
express written permission by MAPPER Lithography. Should you have received
this e-mail, attachments and its content by mistake, please bring this to
our attention and destroy this e-mail and attachments in full. Thank you.


|---------+---------------------------->
|         |           Nadav Horesh     |
|         |           <nadavh at visionsen|
|         |           se.com>          |
|         |                            |
|         |           15/12/2003 14:13 |
|         |                            |
|---------+---------------------------->
  >------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                              |
  |       To:       R.Jager at mapperlithography.com                                                                                |
  |       cc:       Peter Verveer <verveer at embl-heidelberg.de>, numpy-discussion at lists.sourceforge.net                           |
  |       Subject:  Re: [Numpy-discussion] Convolve returning zero array                                                         |
  >------------------------------------------------------------------------------------------------------------------------------|




1. Can you post an example?
2. Whenever convolution runs slow because the arrays are large, use FFT
(with a proper padding) --- it can be an order of magnitude (or more)
faster.

   Nadav.

R.Jager at mapperlithography.com wrote:
> Hi Peter,
>
> At first I used numarray 0.6. This morning I have installed 0.8 but the
> results are the same. I will try the convolve functions in the nd_image
> package.
>
> Thanks,
>
> Remco Jager
>
> MAPPER Lithography
> Lorentzweg 1
> 2628 CJ Delft, The Netherlands
> tel.: +31 (0)15 2789439
> fax: +31 (0)15-2789473
> http://www.mapperlithography.com
>
> This e-mail, attachments and (any part of) its content are (i) intended
for
> the named addressee(s) only and (ii) strictly confidential and
proprietary.
> All rights are reserved by MAPPER Lithography. Any unauthorized use,
> disclosure and/or copying are strictly prohibited, except with prior and
> express written permission by MAPPER Lithography. Should you have
received
> this e-mail, attachments and its content by mistake, please bring this to
> our attention and destroy this e-mail and attachments in full. Thank you.
>
>
> |---------+---------------------------->
> |         |           Peter Verveer    |
> |         |           <verveer at embl-hei|
> |         |           delberg.de>      |
> |         |                            |
> |         |           15/12/2003 12:04 |
> |         |                            |
> |---------+---------------------------->
>
>------------------------------------------------------------------------------------------------------------------------------|

>   |
|
>   |       To:       R.Jager at mapperlithography.com,
numpy-discussion at lists.sourceforge.net
|
>   |       cc:
|
>   |       Subject:  Re: [Numpy-discussion] Convolve returning zero array
|
>
>------------------------------------------------------------------------------------------------------------------------------|

>
>
>
>
> Hi Remco,
>
> Sounds like a bug. Which version of numarray do you use? Version 0.8 of
> numarray should have appeared on sourceforge now. If the convolve in that
> version does still not work, you could try out the convolution function
in
> the new nd_image package that is part of numarray 0.8. If that does not
> work,
> let me know since I am the author of that package, and will fix problems
> with
> it.
>
> Cheers, Peter
>
> On Monday 15 December 2003 11:24, R.Jager at mapperlithography.com wrote:
>
>>Hi list,
>>
>>I already posted this on the numarray forum on freshmeat, but Jay T
>
> Miller
>
>>advised me to post my problem to this list. OK, now for the problem: I
>
> try
>
>>to convolve a Gaussian distribution with a binary pattern. For small
>
> values
>
>>of the sigma of the Gaussian distribution the convolution returns an
>
> array
>
>>of zeros. For a large value the results are OK.
>>I did some more research and found out that the zero array is returned if
>>the length of the Gaussian is smaller than the length of the binary
>>pattern. In the function call the Gaussian is the kernel and the binary
>>pattern is the data. The convolution mode is 'SAME'. I have swapped the
>>data and kernel in the convolve function call, but this has no influence
>
> on
>
>>the result, as this is swapped again in convolve.py. A quick and dirty
>>workaround is to always make the Gaussian distribution longer than the
>>binary pattern, but for very large binary patterns this increases the
>>calculation time significantly. Does anyone have an idea how to solve
>
> this
>
>>properly?
>>
>>Met vriendelijke groeten,
>>
>>Remco Jager
>>
>>MAPPER Lithography
>>Lorentzweg 1
>>2628 CJ Delft, The Netherlands
>>tel.: +31 (0)15 2789439
>>fax: +31 (0)15-2789473
>>http://www.mapperlithography.com
>>
>>This e-mail, attachments and (any part of) its content are (i) intended
>
> for
>
>>the named addressee(s) only and (ii) strictly confidential and
>
> proprietary.
>
>>All rights are reserved by MAPPER Lithography. Any unauthorized use,
>>disclosure and/or copying are strictly prohibited, except with prior and
>>express written permission by MAPPER Lithography. Should you have
>
> received
>
>>this e-mail, attachments and its content by mistake, please bring this to
>>our attention and destroy this e-mail and attachments in full. Thank you.
>>
>>
>>
>>
>>
>>
>>-------------------------------------------------------
>>This SF.net email is sponsored by: SF.net Giveback Program.
>>Does SourceForge.net help you be more productive?  Does it
>>help you create better code?  SHARE THE LOVE, and help us help
>>YOU!  Click Here: http://sourceforge.net/donate/
>>_______________________________________________
>>Numpy-discussion mailing list
>>Numpy-discussion at lists.sourceforge.net
>>https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
> --
> Dr. Peter J. Verveer
> Cell Biology and Cell Biophysics Programme
> European Molecular Biology Laboratory
> Meyerhofstrasse 1
> D-69117 Heidelberg
> Germany
> Tel. : +49 6221 387245
> Fax  : +49 6221 387306
>
>
>
>
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?  SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>












More information about the Numpy-discussion mailing list