[Insight-users] RGB images from Visible Human Dataset
Stefan Lindenau
stefan . lindenau at gmx . de
Fri, 31 Oct 2003 13:48:56 -0500
Hi Luis,
thank you for the good explanation.
I have tried the script you attached but it is not working for me. I
just made some adaptations regarding the filename and the slicesize
since I am not using cropped images from the female dataset.
But whenever I execute the script I get the following error:
reorganizing c:\avf1262a.raw into vwavf12.raw
Traceback (most recent call last):
File "C:\reorder VHD.py", line 27, in ?
reorderRGB("c:\\avf1262a.raw")
File "C:\reorder VHD.py", line 18, in reorderRGB
rgbfile.write( gdata[i] )
IndexError: string index out of range
In the stackview I see that the variable i has the value 20.
I think the reason for this failure is that the rdata,gdata,bdata
strings are not filled as expected.
Iam using Python 2.3.2 with TK 8.4 on Windows.
That is the code I am using:
------------------------------
#!/usr/bin/python
import glob
def reorderRGB( filename ):
slicesize = 2048 *1216
file=open(filename)
rdata=file.read( slicesize )
gdata=file.read( slicesize )
bdata=file.read( slicesize )
file.close()
outfilename="vw"+filename[3:8]+".raw"
print "reorganizing ", filename, " into " , outfilename
rgbfile=open( outfilename, 'w' )
for i in range(0,slicesize-1):
rgbfile.write( rdata[i] )
rgbfile.write( gdata[i] )
rgbfile.write( bdata[i] )
rgbfile.close()
def printfile( filename ):
print filename
listfiles=glob.glob("avf1*.raw")
for filename in listfiles:
reorderRGB( filename )
print "Files reorganized"
------------------------------
Thank you
Stefan