MantisBT - VTK
View Issue Details
0001641VTK(No Category)public2005-03-03 12:582016-08-12 09:54
lydia 
Kitware Robot 
normalmajoralways
closedmoved 
 
 
0001641: bug in vtkImageviewer2 when one of the image dimension exeeds 512!!!
already posted a mail concerning this problem but now I am quite sure that the problem is in the class vtkImageViewer2. This class cannot display images when either the width or the height exceeds 512!!

Below is my code and attached a stack of MRI images..

you will notice the following:

1. With vtkImageViewer2, the display is not corret (the second dimension of the image is 611)

2. If you use vtkImageViewer instead of vtkImageViewer2, it will properly..( Strange! isn't it?)

3. Another remark, if you replace i by 5 for example or any number less than dim[2], and if you set up a breakpoint after viewer->Render(), you will notive that the first display is done properly, then if you continue inside the "while", the same image will not be displayed properly...

Hope all these information will help vtk developers to find the bug and help me because I spent so many time in debugging my program thinking that the bug was from me...

Thanks in advance

#include "vtkStructuredPointsReader.h"

#include "vtkStructuredPoints.h"

#include "vtkImageImport.h"

#include "vtkImageViewer.h"

#include "vtkImageViewer2.h"

 

void main ()

{

vtkStructuredPointsReader *reader=vtkStructuredPointsReader::New();

reader->SetFileName("C:/TEMP/MRI.vtk");

reader->Update();

int dim[3]; double spacing [3];

reader->GetOutput()->GetDimensions(dim);

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

vtkStructuredPoints *dcm_volume=vtkStructuredPoints::New();

dcm_volume->SetDimensions(dim[0],dim[1],dim[2]);

dcm_volume->SetScalarType(VTK_UNSIGNED_CHAR);

dcm_volume->SetNumberOfScalarComponents(1);

dcm_volume->AllocateScalars();

dcm_volume->DeepCopy(reader->GetOutput());

vtkImageViewer2 *viewer = vtkImageViewer2::New();

int i=0;

while (i<dim[2])

{

unsigned char *vol1= new unsigned char[(dim[0]*dim[1])/sizeof( unsigned char)];

memmove(vol1, (unsigned char *)dcm_volume->GetScalarPointer()+i*(dim[0]*dim[1]),dim[0]*dim[1]);


vtkImageImport *importer_pro=vtkImageImport::New();

importer_pro->SetWholeExtent(0,dim[0]-1,0,dim[1]-1,1,1);

importer_pro->SetDataExtent(0,dim[0]-1,0,dim[1]-1,1,1);

importer_pro->SetDataSpacing(1,1,1);

importer_pro->SetDataOrigin(0, 0,0);

importer_pro->SetDataScalarType(VTK_UNSIGNED_CHAR);

importer_pro->SetNumberOfScalarComponents(1);

importer_pro->SetImportVoidPointer((unsigned char *) vol1);

importer_pro->Update();


viewer->SetSize(500,500);

viewer->SetInput(importer_pro->GetOutput() );

viewer->SetZSlice(1);

viewer->SetColorWindow(255);

viewer->SetColorLevel(127.5);

viewer->Render();

i++;

delete [] vol1;

importer_pro->Delete();

}

}
No tags attached.
Issue History
2008-11-30 09:23Mathieu MalaterreAssigned ToMathieu Malaterre => François Bertel
2008-11-30 20:19François BertelAssigned ToFrançois Bertel =>
2011-06-16 13:11Zack GalbreathCategory => (No Category)
2016-08-12 09:54Kitware RobotNote Added: 0036774
2016-08-12 09:54Kitware RobotStatusexpired => closed
2016-08-12 09:54Kitware RobotResolutionopen => moved
2016-08-12 09:54Kitware RobotAssigned To => Kitware Robot

Notes
(0036774)
Kitware Robot   
2016-08-12 09:54   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.