[Tutor] Reading a "Raw "Image File

Wayne Watson sierra_mtnview at sbcglobal.net
Sun Apr 12 21:41:50 CEST 2009


I can read a raw of 640x480 bytes with:

    raw_file=open('sent_internal.raw')
    raw_image=raw_file.read()

It likely contains a lot of 0 values, black=0. The result above is a
string of 242 characters. I'm guessing the 0's were ignored, and only >0
values were kept. If so, how do I get all 307200 bytes into a read?
Whoops ... Ah, I missed 'rb'; however, I want to continue.

I found the minimum value among the first 242 items to be 31 without the
'rb'. Among the 307200, I found it to be 150, which I believe is
correct. That is, there are pixels in the image that are pretty bright.
So what weirdness took place w/o the 'rb'? Why no 150?

One more question, when I tried (no 'wb') read(size=307200), why di read
balk at size, syntactically.

-- 
           Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

             (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
              Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

           All the neutrons, and protons in the human body occupy
           a cube whose is 5.52*10**-6 meters. That adds up to a
           150 pound person. It's not a surprise that we are mostly
           space. (Calculation by WTW)






More information about the Tutor mailing list