[vtkusers] Reading and writing three dimensional vector fields

Lodron, Gerald Gerald.Lodron at joanneum.at
Mon Jan 18 09:37:35 EST 2010



Hello

I am trying to read and write three dimensional vector fields which means vtkImageData of dimensionality 3 and 3 components of type double.

Which writer/reader combination will be best?

 I already stored it using tiff writer:

                        vtkImageData* image = m_DeformationField;

                        if(strcmp(image->GetScalarTypeAsString(),"double")==0) //tiff doesnt like double
                        {
                                caster = vtkImageCast::New();
                                caster->SetInput(m_DeformationField);
                                caster->SetOutputScalarTypeToFloat();
                                image = caster->GetOutput();
                                image->Update();
                        }

                        vtkSmartPointer<vtkTIFFWriter> writer = vtkTIFFWriter::New();
                        writer->SetFileName(strFileName.c_str());
                        writer->SetInput(image);
                        writer->SetFileDimensionality(m_DeformationField->GetDataDimension());
                        writer->SetCompression(vtkTIFFWriter::NoCompression);
                        writer->Write();

Which worked but when reading it i get the error "Problem reading RGB image":


                vtkSmartPointer<vtkTIFFReader> reader = vtkTIFFReader::New();
                reader->SetFileName(strFileName.c_str());
                reader->SetFileDimensionality(3);
                reader->Update();

Thanks for help




More information about the vtkusers mailing list