scipy.signal.convolve2d() clips off part of my image

mike kreiner mike.kreiner at gmail.com
Tue Jan 25 00:45:07 EST 2005


I'm using the convolve2d(image, mask) function from scipy to blur an
image. The image I'm using is 512 by 384. When I display the image that
convolve2d returns, the the left-most square of pixels (388 by 388)
turn out fine, blurred and everything, however the right side of the
image is all black.

I've uploaded the practice image to: http://tinypic.com/1g3iox
The output image is: http://tinypic.com/1g3iv9

here's what I entered at the intereactive window:

>>> import scipy
>>> img = scipy.imread("c:\\practice.jpg",flatten=True)
>>> img.shape
(384, 512)
>>> mask =
(1.0/115)*scipy.array([[2,4,5,4,2],[4,9,12,9,4],[5,12,15,12,5],[4,9,12,9,4],[2,4,5,4,2]])
>>> blurredImg = scipy.signal.convolve2d(img, mask)
>>> scipy.imsave("c:\\blurred.jpg",blurredImg)

Also, I noticed that the shape attribute is (384, 512), even though
windows and my image editor say the image is 512 by 384. Could this
have something to do with the reason convolve2d() only works right on
the left-most 388 by 388 pixels? Thanks for any help.

-Mike Kreiner




More information about the Python-list mailing list