A1g
A1g

Reputation: 93

Read and display a binary image file in python

I am new to python,
I have a binary image file (unsigned 16-bit format and 512x512 pixel in size),but while using a python code I am getting error "ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"

I am running the code as shown

import numpy as nmp
from matplotlib import pylab as pt

I = nmp.fromfile('raw.dat', dtype='int16', sep="")
I = I.reshape([512, 512])

pt.imshow(I)
pt.show(I)

can anybody please tell me where I am doing wrong?

Upvotes: 1

Views: 7609

Answers (1)

Iguananaut
Iguananaut

Reputation: 23366

pylab.show() does not take an array as an argument. It just shows what you've already plotted with imshow.

Upvotes: 2

Related Questions