[vtkusers] fill vtkImageData with user data

nitin v nitinvasishtha at cdacnoida.in
Wed Jul 5 06:00:09 EDT 2006


 
hi all,
iv tried this code but it's not working....
basically the image is not getting generated...only some jagged lines r
displayed........
plz help...
nitin 
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
> 
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060705/b01da857/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 1431 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060705/b01da857/attachment.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 20284 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060705/b01da857/attachment.gif>


More information about the vtkusers mailing list