[vtkusers] Re: Modify scalar values

camilo.jimenez at spymac.com camilo.jimenez at spymac.com
Thu Jan 20 17:18:56 EST 2005


I recommend you the vtkImageExport and vtkImageImport classes.

I don't use these, but I use something like this (suppose your vtkImageData is 
Image)


int sx = Image->GetDimensions()[0],
    sy = Image->GetDimensions()[1],
    sz = Image->GetDimensions()[2];

unigned short *ImgPtr = NULL;
Image->SetScalarTypeToUnsignedShort( );
ImgPtr = (unsigned short*)Image->GetScalarPointer( ) ;


for( int k=0; k<sz; k++ ){
     for( int j=0; j<sy; j++ ){
        for( int i=0; i<sx; i++ ){

           //Do your stuff here
       }
    }
}



Hope this work for you




More information about the vtkusers mailing list