Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41119

RE: Reversing bits in a byte

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 <Robert.Flintham@uhb.nhs.uk>
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 <Robert.Flintham@uhb.nhs.uk>
To "'python-list@python.org'" <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 <DFBB66D7CAE80545A91347000FC76D5E022E672B6D@BOURNE.xuhb.nhs.uk>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3226.1363094916.2939.python-list@python.org> (permalink)
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

Show key headers only | View raw


Sorry, the subject line was for a related question that I decided not to ask, I forgot to change it when I changed my email.  I've changed it now!

I'm using Python 3.3 on Windows with the pydicom module (http://code.google.com/p/pydicom/).  Using pydicom, I've ended up with a "bytes" object of length (512*512/8 = 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:
'b\x00\x00\x00.....'

I can unpack this to a tuple of the 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.

I wasn't sure which GUI library to use, so haven't specified one.  As it's Python 3, Tkinter is available.  I also have matplotlib and numpy installed, and PIL.

Ideally, I'd like to be able to access the pixel data in the form of a numpy array so that I can perform image-processing tasks on the data.

So now that I've explained myself slightly more fully, does anyone have any thoughts on how to do this?

All the best,
Rob

Robert Flintham
Trainee Clinical Scientist - MRI

Tel:      +44 (0)121 371 7000
Email:       Robert.Flintham@uhb.nhs.uk
Web:      http://www.uhb.nhs.uk

We're bringing the world's most advanced cancer treatments to Birmingham.
Find out more at www.qecancerappeal.org or text QEHB01 £5 to 70070 to donate £5 to our appeal.

RRPPS
Medical Physics - University Hospitals Birmingham NHS Foundation Trust
63 Melchett Road, Kings Norton,
Birmingham, B30 3HP


ð Delivering the best in care



-----Original Message-----
From: Python-list [mailto:python-list-bounces+robert.flintham=uhb.nhs.uk@python.org] On Behalf Of Dave Angel
Sent: 12 March 2013 12:47
To: python-list@python.org
Subject: Re: Reversing bits in a byte

On 03/11/2013 11:32 AM, Robert Flintham wrote:
> Hi,
>
> I have a 'bytes' object which contains a simple bitmap image (i.e. 1 bit per pixel).  I can't work out how I would go about displaying this image.  Does anyone have any thoughts?
>
> All the best,
> Rob
>
>

How does your subject line relate to your question?

But more importantly, what version of Python, what OS, and which GUI library (wxpython, qt, etc.) are you used to?  Specify those, and somebody familiar with that particular library will probably pop up with an answer.



--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list

DISCLAIMER:
This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has 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 this e-mail or any attachments, as this may be unlawful.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Reversing bits in a byte Robert Flintham <Robert.Flintham@uhb.nhs.uk> - 2013-03-12 13:28 +0000

csiph-web