[slicer-users] Mismatch between the image origin stored in vtk-files and the one displayed by Slicer

Christian Bauer christian-bauer at uiowa.edu
Mon Jul 26 13:30:37 EDT 2010


Hi!
        
        I'm using Slicer 3.6 and found that there is a mismatch between
        the
        image origin stored in vtk-files and the one displayed by
        slicer.
        
        When I use the itk code below to create a vtk-file where I set
        the
        origin to 10/20/30 and I read the file with Slicer (Add
        volume...) the image origin is displayed as -10/-20/30.
        I also tried to store the image as .nii, .nrrd, and .hdr files,
        always with the same result.
        
        Using ParaView for reading the files, the origin is the one I
        expect.
        
        I guess this behavior is related to some image orientation
        issues I
        don't understand. I hope, someone can explain this behavior to
        me.
        
        Thanks,
        Christian
        
        #include <itkImage.h>
        #include <itkImageFileWriter.h>
        
        int main(int argc, char**argv)
        {
            typedef itk::Image<short, 3> ImageType;
            typedef itk::ImageFileWriter< ImageType > ImageWriterType;
            
            ImageType::Pointer image = ImageType::New();
            ImageType::RegionType region;
            region.SetSize(0, 10);
            region.SetSize(1, 10);
            region.SetSize(2, 10);
            image->SetRegions( region );
            ImageType::PointType origin;
            origin[0]=10;
            origin[1]=20;
            origin[2]=30;
            image->SetOrigin( origin );
            image->Allocate();
                    
            ImageWriterType::Pointer imageWriter =
        ImageWriterType::New();
            imageWriter->SetFileName( "test.vtk" );
            imageWriter->SetInput( image );
            imageWriter->Update();
        }
        
        




More information about the slicer-users mailing list