Setting an Image File Values

W. Watson wolf_tracks at invalid.inv
Tue May 4 00:48:41 EDT 2004


I have a 640x480 b/w bmp image file that can be converted to a dat file. I would like 
to convert the value of each pixel that is below say 120 units to exactly 40 units. 
I've never written a python program in my life. However, the manual for the image 
application I'm looking at show the following line to create a mask.dat file of size 
640x480 bytes with every value set to 40:
   python -c "open('mask.dat','w').write(chr(40)*640*480)"
I suspect a program to do what I need is not much more complicated. Can someone 
construct a program for me to do the job? It'll probably be the only python program I 
ever need.

-- 
       Wayne T. Watson (121.015 Deg. W, 39.262 Deg. N, 2,701 feet, Nevada City, CA)
                      -- GMT-8 hr std. time, RJ Rcvr 39° 8' 0" N,  121° 1' 0" W

                Two laws Newton and Einstein didn't discover:
                    1. Time is money.
                    2. Matter will be damaged in direct proportion to its value.

                         Web Page: <home.earthlink.net/~mtnviews>
                         sierra_mtnview -at- earthlink -dot- net
            Imaginarium Museum: <home.earthlink.net/~mtnviews/imaginarium.html>



More information about the Python-list mailing list