[vtkusers] correction of spacing

Bartosz Wiklak bwiklak at gmail.com
Mon Nov 24 17:25:55 EST 2008


Hi, thanks for answear

If I understand, you suggested to use reader->Update() or
reader->GetOutput()->Update().
It doesn't work for me, I still can see that spacing is wrong.

I'm not sure, but after some actions UpdateInformation is called automatically.
Sample code:

  spacing[2] = 1.5;

  reader->GetOutput()->SetSpacing(spacing);

  reader->Update();

  reader->GetOutput()->UpdateInformation();

  reader->GetOutput()->GetSpacing(spacing);


or

  spacing[2] = 1.5;

  reader->GetOutput()->SetSpacing(spacing);

  reader->GetOutput()->Update();

  reader->GetOutput()->UpdateInformation();

  reader->GetOutput()->GetSpacing(spacing);

Gives me spacing[2]==1.0


What can I do?

Bartek


On Mon, Nov 24, 2008 at 7:58 PM, Dominik Szczerba <dominik at itis.ethz.ch> wrote:
> Haha! - see my recent posts.
> Try updating the pipeline with the correct spacing.
>
> Dominik
>
> Bartosz Wiklak wrote:
>>
>> Hello,
>>
>> I'm using GDCM  ( vtkGDCMImageReader ) to read some MR data.
>> I switched  SetComputeZSpacing on, set SetZSpacingTolerance to 1e-2
>> and used IPPSorter.
>> This is my code:
>>
>>  vtkGDCMImageReader *reader = vtkGDCMImageReader::New();
>>
>>
>>
>>        std::vector<std::string> filenames;
>>
>>
>>
>>        gdcm::Directory d;
>>
>>
>>
>>        d.Load( "/home/basiek/Dokumenty/dcms/testGLOWA/1", false );
>>
>>
>>
>>        filenames = d.GetFilenames();
>>
>>        gdcm::IPPSorter s;
>>
>>        s.SetComputeZSpacing( true );
>>
>>        s.SetZSpacingTolerance( 1e-2 );
>>
>>        bool b = s.Sort( filenames );
>>
>>        if( !b )
>>
>>                {
>>
>>                std::cerr << "Failed to sort:" << "s" << std::endl;
>>
>>                return 1;
>>
>>                }
>>
>>
>>
>>        std::cout << "Sorting succeeded:" << s.GetZSpacing() << std::endl;
>>
>>        //s.Print( std::cout );
>>
>>
>>
>>        const std::vector<std::string> & sorted = s.GetFilenames();
>>
>>
>>
>>        vtkStringArray *files = vtkStringArray::New();
>>
>>        std::vector< std::string >::const_iterator it = sorted.begin();
>>
>>        for( ; it != sorted.end(); ++it)
>>
>>        {
>>
>>        const std::string &f = *it;
>>
>>        files->InsertNextValue( f.c_str() );
>>
>>        }
>>
>>        reader->SetFileNames( files );
>>
>>        reader->Update();
>>
>> I'm getting zspacing 1.5 whitch is ok, but in the
>> reader->GetOutput()->GetSpacing(spacing) I'm getiing spacing[2]==1.0 !
>>
>> What am I doing wrong?
>> I tried to set pixelspacing manually but after
>> reader->GetOutput()->UpdateInformation() I'm with old, wrong value
>> again.
>>
>> When I make reslice in coronal I have eyes shaped like ellipses. I
>> tired to set pixelspacing for vtkImageReslice:
>> reslice->SetOutputSpacing( spacing[0], spacing[1], 1.5 );
>>
>> but this also makes no difference regardless
>> reslice->GetOutput()->UpdateInformation().
>>
>> Can someone point me in the right direction?
>> _______________________________________________
>> This is the private VTK discussion list.
>> Please keep messages on-topic. Check the FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
> --
> Dominik Szczerba, PhD
> Computational Physics Group
> IT'IS Foundation
> http://www.itis.ethz.ch
>



More information about the vtkusers mailing list