Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.07; 'here?': 0.09; 'image,': 0.09; 'pixels': 0.09; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'numpy': 0.16; 'received:192.168.1.4': 0.16; 'tuple': 0.16; 'wrote:': 0.18; 'shape': 0.19; 'starts': 0.20; 'example': 0.22; 'import': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'array': 0.29; 'img': 0.31; 'but': 0.35; 'representing': 0.36; 'so,': 0.37; 'follows:': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'new': 0.61; 'skip:n 10': 0.64; 'shape.': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=ZuVjKrLG c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=aoAcgTy3oA8A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=Nbke5b1Zu7KwLaZh01IA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett:2500 Date: Wed, 19 Nov 2014 02:52:42 +0000 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: scipy shape References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416365571 news.xs4all.nl 2879 [2001:888:2000:d::a6]:34790 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81022 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.