[vtkusers] vtkImageReader
Oliver Fleig
Oliver.Fleig at univ-rennes1.fr
Thu Jan 25 10:33:25 EST 2001
Naveen Kumar Polapally wrote:
> I have a task where i should be able to read any part of the volume, i see
> that using vtkImageReader i have to read slice by slice.
>
> suppose i have 0 511 0 511 1 100, i want to be able to read
> 0 255 0 255 1 50.
> with vtkImageReader even if i use
> setDataVOI(0,255,0,255,1,50) i still have to give the whole extent
> setDataExtent(0,511,0,511,1,100).
>
> Is the any other reader which can read only a subvolume, with out any
> restrictions.
unsigned char * volume_raw = new unsigned char[xdim*ydim*zdim];
volfile.read(volume_raw,xdim*ydim*zdim*sizeof(unsigned char)) ;
vtkImageImport * vol = vtkImageImport :: New() ;
vol-> SetDataScalarTypeToUnsignedChar ();
vol->SetDataExtent(0,xdim-1,0,ydim-1,0,zdim-1);
vol->CopyImportVoidPointer ( (void*) volume_raw,
xdim*ydim*zdim*sizeof(unsigned char) ) ;
delete[] volume_raw;
To read a sub volume used the appropriate offsets!!
I think there is also a version that does not copy over.
Cheers
Oliver
--
mailto:Oliver.Fleig at univ-rennes1.fr
More information about the vtkusers
mailing list