Nadav Horesh schreef:
> I think you have a problem of overflow in r5: You may better use utin64
> instead of uint32.
>
> Nadav.
>
>
Nadav,
My problems were due to trying to do two things at once.
The code below does what I want and it is very fast. I see the power of
numpy now:
import numpy as NU
import numpy.numarray.nd_image as NI
BW = NU.zeros((5,5), dtype=NU.uint8)
AR = NU.zeros((5,5), dtype=NU.uint32)
DA = NU.zeros((5,5), dtype=NU.uint32)
LA = NU.zeros((5,5), dtype=NU.uint32)
DC = 4278190280
LC = 4278241280
BW[1,1] = 1
BW[2,2] = 1
AR[:] = DC
AR[1,1] = LC
AR[2,2] = LC
DA[:] = DC
LA[:] = LC
kernel = NU.array([[0,1,0], \
[1,1,1], \
[0,1,0]]).astype(NU.uint8)
print "AR=\n", AR
#convolve
r1 = NI.convolve(BW, kernel).astype(NU.uint8)
r2 = (NI.convolve(BW, kernel) == 1).astype(NU.uint8)
print "r1=\n",r1
print "r2=\n",r2
# create 32-bit array using results from convolve as mask
AR = NU.array(DA, copy=1)
NU.putmask(AR, r2, LA)
print "AR=\n", AR
------------------------------------------------------------------------------
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion