Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bizarre .raw file in the following format, that I need to open for a class project. It has the following structure using the example of a 487x414 photo:

  • The number of rows is two un-signed bytes (01E7)
  • The number of columns is two un-signed bytes (019E)
  • The number of bits representing each pixel (this will always be 8)
  • The actual picture data

The project is to run edge detection on the .raw file, but the professor said I should be able to open it with any old image editing software (apparently, he expects me to be prompted with a window where I set the number of bytes in the header), so I tried the following to no avail:

  • Photoshop Elements
  • Adobe Lightroom
  • ImageMagick
  • Gimp
  • DCRaw

I'm dual booting Ubuntu and Windows, so if anyone has any ideas on how I could get this file displayed, (I'm currently trying to load it into OpenCV as a histogram, but I would like to have something to check my result against), it would be greatly appreciated.

share|improve this question
Try ufraw. I use it to edit raw files from my camera (nikon) and as far as I'm aware it has support for most other formats. Has to be worth a try. – Holloway Jul 21 '14 at 13:48
I did try that, but unfortunately it didn't work. Thanks for reminding me of this unanswered question. – Seanny123 Jul 21 '14 at 16:47
up vote 0 down vote accepted

I ended up having to write a custom Python script which you can find here. Here's the important part.

#Load the raw file
f = open(filename,'rb') # switch to command line args later
#Because the byte order is weird
a =
b =
#First line is rows
rows = int((b+a).encode('hex'), 16)
a =
b =
#Second line is columns
cols = int((b+a).encode('hex'), 16)
#Last byte is encoding, but we're just going to ignore it
#And everything else is 8 bit encoded, so let's load it into numpy and display it with matplotlib
bin_image = np.fromstring(, dtype=np.uint8)
#Change the shape of the array to the actual shape of the picture
bin_image.shape = (cols, rows)

fig = pylab.figure()
#Display the original image
pylab.imshow(bin_image, cmap=cm.gray)
share|improve this answer
If this worked, mark it as accepted to remove this question from unanswered. – Holloway Jul 22 '14 at 7:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.