3

I want to try view the image using spyder python as in:

skydrive share the image is:

  • uint16 (10-bit)
  • width:1376 pixel, height: 960 pixel
  • no header
  • bayer pattern blue-green, green-red

What python script is suitable?

Thanks.

5
  • Please have a try on this first and post the code snippet or error if you are facing some issue Commented Feb 25, 2013 at 14:35
  • Look here Commented Feb 25, 2013 at 15:22
  • also note that this is about "image processing" not about the "processing" programming language. Commented Feb 25, 2013 at 16:25
  • You could split this into 3 or 4 steps and each would be a question on its own. 1) How to read the image. 2) Bayer demosaicing. 3) Converting from a linear colorspace to something gamma corrected such as sRGB. 4) Applying white balance or color correction. Commented Feb 25, 2013 at 18:10
  • this is what I get from [link]kyb.tuebingen.mpg.de/?id=227 <!-- language: lang-none --> fin = open('001.raw', 'rb') s = fin.read() fin.close() arr = array.array('H', s) arr.byteswap() img = numpy.array(arr, dtype='uint16').reshape(960,1376) imshow(img, gray()); Commented Feb 26, 2013 at 15:58

1 Answer 1

4

Here is one way.

Start with imports

from matplotlib import pyplot as plt
import numpy as np

Now allocate the space

image = np.empty((1376,960), np.uint16)

Read the image into your array:

image.data[:] = open('20_1-20ms.raw').read()

Display it:

plt.imshow(image)
Sign up to request clarification or add additional context in comments.

2 Comments

As far as I can tell, this doesn't work on color data (i.e., a stack of 3 images, one for each color). Matplotlib's imshow requires either floats or int8s to produce a reasonable RGB image. Attempting to call it with int16s will produce garbled noise. You must either bitshift your 10 bit data to 8 bit data, or convert to float e.g., im_float = im_int / (2**10 - 1.).
I tried this out to read a .raw file but I'm getting this error: NotImplementedError: memoryview slice assignments are currently restricted to ndim = 1.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.