Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > RE: Reversing bits in a byte

Reply
Thread Tools

RE: Reversing bits in a byte

 
 
Robert Flintham
Guest
Posts: n/a
 
      03-12-2013
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 oflength (512*512/8 = 3276 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 havematplotlib 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: http://www.velocityreviews.com/forums/(E-Mail Removed)
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 [mailtoython-list-bounces+robert.flintham=(E-Mail Removed)] On Behalf Of Dave Angel
Sent: 12 March 2013 12:47
To: (E-Mail Removed)
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), pleasenotify 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Reversing bits in a byte Oscar Benjamin Python 2 03-12-2013 04:00 PM
Re: Reversing bits in a byte Oscar Benjamin Python 0 03-12-2013 02:59 PM
RE: Reversing bits in a byte Robert Flintham Python 0 03-12-2013 01:31 PM
Re: Reversing bits in a byte Tim Chase Python 0 03-12-2013 01:20 PM
Re: Reversing bits in a byte Dave Angel Python 0 03-12-2013 12:46 PM



Advertisments