[vtkusers] Fwd: Loading C array as vtkImage

Anant Vemuri ajar108 at gmail.com
Thu Jun 17 21:27:59 EDT 2010


You can import a pointer from a C array into vtkImageData using
vtkImageImport


fromIpl2Vtk( float *_src, vtkImageData* _dest )
{
    vtkImageImport *importer = vtkImageImport::New();
    int channels = 3;
    if ( _dest )
    {
        importer->SetOutput( _dest );
    }
    else
    {
        _dest = vtkImageData::New();
     }
    importer->SetDataSpacing( 1, 1, 1 );
    importer->SetDataOrigin( 0, 0, 0 );
    importer->SetWholeExtent(   0, _src.size().width-1, 0,
_src.size().height-1, 0, 0 );
    importer->SetDataExtentToWholeExtent();
    importer->SetDataScalarTypeToFloat(); /// Check vtkImageImport
documentation for this
    importer->SetNumberOfScalarComponents( channels );  /// Use this for
importing a colour image.
    importer->SetImportVoidPointer( _src );
    importer->Update();
}

-----------
Anant S. Vemuri
email: ajar108 at gmail.com




On Fri, Jun 18, 2010 at 5:46 AM, Prathamesh Kulkarni <
prathameshmkulkarni at gmail.com> wrote:

> Hello,
>
> I am new to vtk.
> Could anyone point me out to an example of loading a C float array as
> a vtkImage and rendering it?
>
> Thanks,
> Prathamesh
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100618/3c03a184/attachment.htm>


More information about the vtkusers mailing list