Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'scaling': 0.05; 'whatever.': 0.07; 'array.': 0.09; 'from:addr:python': 0.09; 'subject:files': 0.09; 'subject:image': 0.09; 'wrote:': 0.14; "'rb')": 0.16; 'factor,': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'matplotlib': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'numpy': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'reply-to:addr :python-list': 0.16; 'subject:raw': 0.16; 'pil': 0.19; 'header:In- Reply-To:1': 0.21; 'received:84': 0.25; 'problem': 0.28; 'skip:i 30': 0.29; 'array': 0.30; 'solved': 0.30; 'subject:working': 0.30; 'to:addr:python-list': 0.33; 'error': 0.33; 'thinking': 0.34; 'header:User-Agent:1': 0.35; 'reply-to:addr:python.org': 0.35; 'data,': 0.36; 'data.': 0.37; 'could': 0.38; 'but': 0.38; 'data': 0.38; 'ok,': 0.38; 'subject:: ': 0.38; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'order': 0.62; 'skip:n 30': 0.63; 'size.': 0.72; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72; '8bit': 0.91 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgsHAIvC901UXebj/2dsb2JhbABTmA2OR3eIdcA/hiQElh+LEQ Date: Tue, 14 Jun 2011 21:26:28 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: python-list@python.org Subject: Re: working with raw image files References: <0cd64f09-bd32-4b67-9266-46003dbea4b7@m4g2000yqk.googlegroups.com> <1f7a452a-8bae-43e0-ab9f-9bfed55ee206@b21g2000yqc.googlegroups.com> <57d6da80-59db-477f-b507-cabf01a2976d@j23g2000yqc.googlegroups.com> <720bec5b-4892-4cd7-83e1-f67ce78591be@y30g2000yqb.googlegroups.com> <71140671-4273-417d-8d2f-3986663acdb2@k16g2000yqm.googlegroups.com> <2c095413-ea59-4339-8419-ae4b688e219d@17g2000prr.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 20 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1308083252 news.xs4all.nl 49184 [::ffff:82.94.164.166]:42182 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:7629 On 14/06/2011 21:13, kafooster wrote: > Ok, I solved the problem with matplotlib > > fileobj = open("hand.raw", 'rb') > data = numpy.fromfile(fileobj,dtype=np.uint16) > data = numpy.reshape(data,(96,470,352)) > imshow(data[:,:,40],cmap='gray') > show() > > the error was caused by different order of data, however it still > reads the dataset as half of it size. whatever. > > please leave the part about .raw, lets just start thinking of it from > level of numpy array. > > I would like to visualize this data with PIL, but PIL works only with > 8bit data. How could I resample my array from 16bit to 8bit? Multiply the numpy array by a scaling factor, which is float(max_8bit_value) / float(max_16bit_value).