fill vtkImageData with user data
David Gobbi
dgobbi at irus.rri.on.ca
Wed Nov 17 11:25:47 EST 1999
Hi Adrian,
Take a look at vtkImageImport, what you are trying to do can
be done as follows:
import = vtkImageImport::New();
import->SetDataExtent(0,511,0,511,0,0);
import->SetDataScalarType(VTK_UNSIGNED_SHORT);
import->SetImportVoidPointer(Array);
import->UpdateWholeExtent();
vtkImageData *outData = import->GetOutput();
The best thing about this is that you don't have to copy the
data, outData will actually use Array as its memory pointer.
- David
--David Gobbi, MSc dgobbi at irus.rri.on.ca
Advanced Imaging Research Group
Robarts Research Institute, University of Western Ontario
On Wed, 17 Nov 1999, Adrian Anner wrote:
> hello
>
> I have the data from a Picture in an 2d-Array (dim 512,512). Now I want
> write this data to vtkImageData.
>
> I tried the following but it didn't work :
>
> vtkImageData *outData = vtkImageData::New();
> outData->SetWholeExtent (0, 511, 0, 511, 0, 0);
> outData->SetScalarType(VTK_UNSIGNED_SHORT);
>
> unsigned short *ptr;
>
> for (int y = 0; y <512;y++)
> {
> for (int x = 0; x <512; x++)
>
>
> ptr = (unsigned short *)(outData->GetScalarPointer(x, y, 0));
> *ptr = (unsigned short)Array[x][y];
> }
> }
>
> it crashs with the error :
>
> GetScalarPointer:Pixel(1,0,0) not in memory. Current extend = (0,0,0,0,0,0)
>
> I'm using a recent nightly release.
>
> thanks,
>
> Adrian
>
>
>
> -----------------------------------------------------------------------------
> This is the private VTK discussion list. Please keep messages on-topic.
> Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
> To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
> <majordomo at gsao.med.ge.com>. For help, send message body containing
> "info vtkusers" to the same address. Live long and prosper.
> -----------------------------------------------------------------------------
>
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list