scipy shape

MRAB python at mrabarnett.plus.com
Tue Nov 18 21:52:42 EST 2014


On 2014-11-19 02:30, Abdul Abdul wrote:
> I came across an example that starts as follows:
>
> from scipy.ndimage import filters
> img = zeros(im.shape)
>
> What does the second line mean here? Is it setting the image pixels to
> zero? What is "shape" here?
>
It looks like it might be using numpy.

If 'im' is a numpy array representing an image, then its .shape
attribute is giving its 'shape' (a tuple of the sizes of its
dimensions).

numpy.zeros(...) will when return a numpy array of the same shape.

So, it's not setting the image pixels to 0, but creating a new image of
the same shape in which the pixels are 0.



More information about the Python-list mailing list