[Insight-users] RGB images from Visible Human Dataset

Luis Ibanez luis . ibanez at kitware . com
Thu, 30 Oct 2003 15:34:36 -0500


Hi Stefan,

The Visible Human files that you get from the NLM
are *not* arranged as

            RGBRGBRGBRGBRGB.....

but as

            RRRRRRRRRRRRR...
            GGGGGGGGGGGGG...
            BBBBBBBBBBBBB...


That is, in a single file you have the three RGB components
of the slice but arranged as a full Red image followed by a
full Green image, followed by a full Blue image.

The numbers in the filename indicate position of the
slice in millimeter along the scanner table. The a,b,c
indices in the filename are not associated to color but
to a thirds of a millimeter for the sampling.

In other words, you need to reformat the raw data
that you are getting from the NLM (or rearrange the
reading process in such a way that you load the image).

The following is a python script that we used for such
purpose:

--------------------------------------------------
#!/usr/bin/python

import glob

def reorderRGB( filename ):
   slicesize = 570 * 670
   file=open(filename)
   rdata=file.read( slicesize )
   gdata=file.read( slicesize )
   bdata=file.read( slicesize )
   file.close()
   outfilename="vw"+filename[8:-4]+"RGB.raw"
   print "reorganizing ", filename, " into " , outfilename
   rgbfile=open( outfilename, 'w' )
   for i in range(0,slicesize):
     rgbfile.write( rdata[i] )
     rgbfile.write( gdata[i] )
     rgbfile.write( bdata[i] )
   rgbfile.close()


def printfile( filename ):
   print filename


listfiles=glob.glob("avfCROP.1*.raw")
for filename in listfiles:
   reorderRGB( filename )

print "Files reorganized"

------------------------------------------------------



You will find rearranged data from the Visible Woman
dataset in the ITK ftp site:

ftp://public . kitware . com/pub/itk/Data/VisibleWomanHead/Segmentations/

For example:

       VisibleWomanSubsampleRGB.mha
       VisibleWomanSubsampleRGB.raw


--------------------------------------------------


You probably want to manage the original data that
you got from the Visible Human, so simply use the
python script (some tweaking in the filenams maybe
needed because this one was set for the Visible
Woman dataset).  Check that the script is working
ok for one slicebefore you attack all the rest of
the data.


Please let us know if you find any problems,



   Thanks


     Luis



-----------------------
Stefan Lindenau wrote:
> Luis Ibanez wrote:
> 
>> Please find attched to this email the file I used.
>>
> I have compiled the source you sent myself and the generated PNG is
> still as described before. The thumbnail mechanism of Windows and The
> Gimp show both the same result when opening the PNG. I cannot verify if
> the RAW file is in the right format since I have not found a viewer  for
> this format, but I have downloaded the files directly from the NLM ftp
> server so it should be RGB.
> 
>> Let us know what kind of platform are you using,
>> and the version of ITK that you are working with.
> 
> 
> I am using:
> Windows 2000 SP2
> Visual C++ 6.0
> CMake 1.8 patch 1
> Insight Toolkit 1.4.0
> 
> I have attached my CMakeLists.txt but I am quite sure that this file is
> alright.
> 
> Thank you,
> 
> Stefan
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> #only for initial build of project file sets!
> #pls use VC6 Workspace files when available!
> 
> PROJECT("ITK Kitware Code")
> 
> SET( ITKProcessor_SRCS 
>  VisibleHuman.cxx
> ) 
> 
> #find the paths to the ITK lib
> FIND_PACKAGE(ITK)
> IF(ITK_FOUND)
>    INCLUDE(${ITK_USE_FILE})
> ELSE(ITK_FOUND)
>    MESSAGE(FATAL_ERROR
>            "Cannot build InsightApplications without ITK.  Please set 
> ITK_DIR.")
> ENDIF(ITK_FOUND)
> 
> #very important to show the ITK libs to the linker!
> LINK_LIBRARIES (
>   ${ITK_LIBRARIES} 
> )
> 
> 
> 
> 
> 
> ADD_EXECUTABLE(ITKCmdLine VisibleHuman.cxx)
>