Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'birmingham': 0.04; 'binary': 0.05; 'pop': 0.05; 'bits': 0.07; 'pixel': 0.07; 'tkinter': 0.07; 'python': 0.09; 'matplotlib': 0.09; 'pil.': 0.09; 'pixels': 0.09; 'question?': 0.09; 'tuple': 0.09; 'unpack': 0.09; 'gui': 0.11; 'url:)': 0.13; 'library': 0.15; 'represents': 0.15; 'slightly': 0.15; '0).': 0.16; '11:32': 0.16; 'fully,': 0.16; 'ideally,': 0.16; 'kings': 0.16; 'numpy': 0.16; 'presume': 0.16; 'qt,': 0.16; 'reversing': 0.16; 'scientist': 0.16; 'skip:[ 60': 0.16; 'those,': 0.16; 'thoughts?': 0.16; 'trainee': 0.16; 'wrote:': 0.17; 'byte': 0.17; 'integer': 0.17; 'message-----': 0.17; 'received:169.254.1': 0.17; 'specify': 0.17; 'windows': 0.19; 'module': 0.19; 'translate': 0.20; 'foundation': 0.20; 'bit': 0.21; 'os,': 0.22; 'sorry,': 0.22; "world's": 0.22; "i'd": 0.22; 'proprietary': 0.23; 'somebody': 0.23; 'specified': 0.23; "haven't": 0.23; "i've": 0.23; 'received:169.254': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'donate': 0.27; 'question': 0.27; 'forgot': 0.27; 'thoughts': 0.27; 'to?': 0.27; "doesn't": 0.28; 'this?': 0.28; 'installed,': 0.29; 'url:mailman': 0.29; 'array': 0.29; 'received:169': 0.29; 'url:code': 0.29; 'probably': 0.29; "i'm": 0.29; 'related': 0.30; "we're": 0.30; 'error': 0.30; '+44': 0.30; 'url:python': 0.32; 'etc.)': 0.32; "skip:' 20": 0.32; 'skip:- 10': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'version': 0.34; "can't": 0.34; 'changed': 0.34; 'text': 0.34; 'screen': 0.34; 'data,': 0.35; 'robert': 0.35; 'really': 0.36; 'subject:': 0.36; 'but': 0.36; 'url:org': 0.36; '(i.e.': 0.36; 'data.': 0.36; "wasn't": 0.36; 'email addr:python.org': 0.36; 'author': 0.37; 'available.': 0.37; 'best,': 0.37; 'does': 0.37; 'sent:': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'university': 0.38; 'perform': 0.38; 'from:': 0.38; 'object': 0.38; 'some': 0.38; 'received:10': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'recipient': 0.39; 'help': 0.40; 'url:mail': 0.40; 'your': 0.60; 'most': 0.61; 'containing': 0.61; 'email:': 0.62; 'header:Message-Id:1': 0.62; 'received:62': 0.62; 'email name:python-list': 0.62; 'url:p': 0.63; 'received:unknown': 0.63; 'information,': 0.63; 'more': 0.63; 'replying': 0.64; 'our': 0.65; 'decided': 0.65; 'tel:': 0.65; 'importantly,': 0.65; 'medical': 0.66; 'subject': 0.66; 'e-mail.': 0.71; 'answer.': 0.71; 'privileged.': 0.72; 'exclusive': 0.81; '2013': 0.84; '7000': 0.84; 'ask,': 0.84; 'bitmap': 0.84; 'cancer': 0.84; 'clinical': 0.84; 'hospitals': 0.91; 'relate': 0.91; 'treatments': 0.91; 'angel': 0.93; 'recipient(s)': 0.96 From: Robert Flintham To: "'python-list@python.org'" Date: Tue, 12 Mar 2013 13:28:28 +0000 Subject: RE: Reversing bits in a byte Thread-Topic: Reversing bits in a byte Thread-Index: Ac4fIAtaiybJFtM4Tq6if5TY/aQFswABWBYg OLD-MSG-ID: References: <20130311153254.078484489A7@nhs-pd1e-esg101.ad1.nhs.net> <20130312124931.C08D44482E5@nhs-pd1e-esg001.ad1.nhs.net> In-Reply-To: <20130312124931.C08D44482E5@nhs-pd1e-esg001.ad1.nhs.net> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US, en-GB Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SEF-7853D99-ADF1-478E-8894-213D316B8FFA: 1 X-SEF-Processed: 7_0_0_00239__2013_03_12_13_28_33 X-TM-AS-Product-Ver: IMSVA-8.0.0.1467-7.0.0.1014-19710.007 X-TM-AS-Result: No--38.106-60-31-10 X-imss-scan-details: No--38.106-60-31-10; No--38.106-3-31-10; No--38.106-5-31-10 X-TMASE-MatchedRID: YK/9U0bPJGe+J2V2/n6KGVt3XMydUaMXGbJMFqqIm9w06dhcpwNHEFch mZcYZfN1P5XaRnem9eur6XW79NQDeYZJeVoWlbphoMfp2vHck9XW9dMwDTCu0IKe6z7aiX6wW56 hcqQEpdOpDgMfeL8P3lyf2jB/rbzMPp7ZTuOgazrEWFPsMEt58KzIYl5RFrJq+Cckfm+bb6B29S 5jG1aNUHEXbw9Hez3bcXzdddktYEJv4CIIATnzl3QIOMndeKgEGFwEGDRX5uzir9ZdeIDkfH9ed CGGnlBtBOByhf2vjh1nT4YCyYoThI4wrznrcC6n71Wx2uUbPLdBldmDYjwlprYXhr68jbY+1L+j ZYNlMveGAh34IsdJ+YYqpD887gO3mGTohEsziMfKGw01e0pbwUrCzBY4ZVGj+/QnlymiEiWSNTl FDhS1gIzosrpkY5UK6jcAn8j7noBJJDuM6qazTlu4M/xm4KZe1kqyrcMalqW/7bplhbPCQsVJIR TDvqF7A3bjXVqayrLhsL8+JaVWEsaxyAamDzslHPCema1j/6ttSl/nYudvHVVqIv0mjuMGQIG0m Ttr+QavExSmuBldGksoDo7ne8USyTBgz6hl0dd7sw7yO+Y9LO0DrqzpLK29lpyqxIUg/ZTS1nwv JX3LrZkD6OLZ17RPC24oEZ6SpSk+Mqg+CyrtwA== 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363094916 news.xs4all.nl 6983 [2001:888:2000:d::a6]:50812 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41119 Sorry, the subject line was for a related question that I decided not to as= k, I forgot to change it when I changed my email. I've changed it now!=0D=0A=0D= =0AI'm using Python 3.3 on Windows with the pydicom module (http://code.goo= gle.com/p/pydicom/). Using pydicom, I've ended up with a "bytes" object of= length (512*512/8 =3D 32768) containing a 512x512 1-bit bitmap (i.e. each = byte represents 8 pixels of either 1 or 0). When I print this to screen I = get:=0D=0A'b\x00\x00\x00.....'=0D=0A=0D=0AI can unpack this to a tuple of t= he integer representations of binary data, but that doesn't really help as = presume I need the binary (8 digit) representation to be able to translate = that into an image.=0D=0A=0D=0AI wasn't sure which GUI library to use, so h= aven't specified one. As it's Python 3, Tkinter is available. I also have= matplotlib and numpy installed, and PIL.=0D=0A=0D=0AIdeally, I'd like to b= e able to access the pixel data in the form of a numpy array so that I can = perform image-processing tasks on the data.=0D=0A=0D=0ASo now that I've exp= lained myself slightly more fully, does anyone have any thoughts on how to = do this=3F=0D=0A=0D=0AAll the best,=0D=0ARob=0D=0A=0D=0ARobert Flintham=0D=0A= Trainee Clinical Scientist - MRI=0D=0A=0D=0ATel: +44 (0)121 371 7000=0D= =0AEmail: Robert.Flintham@uhb.nhs.uk=0D=0AWeb: http://www.uhb.nh= s.uk=0D=0A=0D=0AWe're bringing the world's most advanced cancer treatments = to Birmingham.=0D=0AFind out more at www.qecancerappeal.org or text QEHB01 = =A35 to 70070 to donate =A35 to our appeal.=0D=0A=0D=0ARRPPS=0D=0AMedical P= hysics - University Hospitals Birmingham NHS Foundation Trust=0D=0A63 Melch= ett Road, Kings Norton,=0D=0ABirmingham, B30 3HP=0D=0A=0D=0A=0D=0A=F0 Deliv= ering the best in care=0D=0A=0D=0A=0D=0A=0D=0A-----Original Message-----=0D= =0AFrom: Python-list [mailto:python-list-bounces+robert.flintham=3Duhb.nhs.= uk@python.org] On Behalf Of Dave Angel=0D=0ASent: 12 March 2013 12:47=0D=0A= To: python-list@python.org=0D=0ASubject: Re: Reversing bits in a byte=0D=0A=0D= =0AOn 03/11/2013 11:32 AM, Robert Flintham wrote:=0D=0A> Hi,=0D=0A>=0D=0A> = I have a 'bytes' object which contains a simple bitmap image (i.e. 1 bit pe= r pixel). I can't work out how I would go about displaying this image. Do= es anyone have any thoughts=3F=0D=0A>=0D=0A> All the best,=0D=0A> Rob=0D=0A= >=0D=0A>=0D=0A=0D=0AHow does your subject line relate to your question=3F=0D= =0A=0D=0ABut more importantly, what version of Python, what OS, and which G= UI library (wxpython, qt, etc.) are you used to=3F Specify those, and some= body familiar with that particular library will probably pop up with an ans= wer.=0D=0A=0D=0A=0D=0A=0D=0A--=0D=0ADaveA=0D=0A--=0D=0Ahttp://mail.python.o= rg/mailman/listinfo/python-list=0D=0A=0D=0ADISCLAIMER:=0D=0AThis email and = any attachments hereto contains proprietary information, some or all of whi= ch may be confidential or legally privileged. It is for the exclusive use o= f the intended recipient(s) only. If an addressing or transmission error ha= s misdirected this e-mail and you are not the intended recipient(s), please= notify the author by replying to this e-mail. If you are not the intended = recipient you must not use, disclose, distribute, copy, print, or rely on t= his e-mail or any attachments, as this may be unlawful.=0D=0A