[vtkusers] how to use dicom file in vtk?

Yan Pingkun pingkun at ieee.org
Fri Dec 10 05:58:04 EST 2004


In your case, the file path under Windows should be like 
"E:\\dicomfile".

On 10-Dec-04, at PM 04:07, <kingaza at gmail.com> wrote:

> thx for your kind help
>
> i have tried to make use of the class vtkDICOMImageReader
> but it tell me that it cann't open the files
> could you help me? i am so puzzled
>
> these are my codes:
>
>
> 	vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
> 	reader->SetDirectoryName("E://dicomfile");
>
> 	int i;
> 	vtkImageReslice             *reslice[9];
> 	vtkImageMagnify             *magnify[9];
> 	vtkImageMapper              *image_mapper[9];
> 	vtkActor2D                  *image_actor[9] ;
> 	vtkRenderer                 *ren[9] ;
>
>
> 	vtkWin32OpenGLRenderWindow *renwin = 
> vtkWin32OpenGLRenderWindow::New();
>
> 	for(i=0;i<9;i++)
> 	{
> 		reslice[i] = vtkImageReslice::New();
> 		magnify[i] = vtkImageMagnify::New();
> 		image_mapper[i]=vtkImageMapper::New();
> 		image_actor[i] = vtkActor2D::New();
>                 ren[i] = vtkRenderer::New();
> 	}
>
> 	for(i=0;i<9;i++)
> 	{	
> 		reslice[i] -> SetInput(reader->GetOutput());
> 		reslice[i] -> SetResliceAxesDirectionCosines(0,1,0,0,0,-1,-1,0,0);
> //-1, 0, 0, 0,-1, 0, 0, 0, -1
>
> 		magnify[i] -> SetInput(reslice[i] -> GetOutput());
> 		magnify[i] -> SetMagnificationFactors(3,3,3);//(IMAGE_MAG_X,
> IMAGE_MAG_Y, IMAGE_MAG_Z);//initial value
> 		magnify[i] -> InterpolateOn();
> 	
> 		image_mapper[i] -> SetInput(magnify[i] -> GetOutput());
> 		image_mapper[i] -> SetColorWindow(255);
> 		image_mapper[i] -> SetColorLevel(127.5);
> 		image_mapper[i] -> SetColorWindow(2000);
> 		image_mapper[i] -> SetColorLevel(1000);
> 		image_mapper[i] -> SetZSlice(20+15*i);
>
> 		image_actor[i] -> SetMapper(image_mapper[i]);
> 		image_actor[i] -> SetPosition(20,20);
>
> 		ren[i] -> AddActor2D(image_actor[i]);
> 		renwin->SetSize(790,630);
> 		renwin->SetPosition(222,64);
> 		renwin->AddRenderer(ren[i]);	
> 	}
>
> 	ren[0]->SetViewport(0.02 ,  0.02 ,  .3133 , .3133);
> 	ren[1]->SetViewport(.35333 ,  0.02 ,  .64667 , .3133);
> 	ren[2]->SetViewport(.68667 ,  0.02 ,  0.98, .3133);
> 	ren[3]->SetViewport(0.02,      .35333,  .31333 , .64667);
> 	ren[4]->SetViewport(.35333 ,  .35333 ,  .64667,  .64667);
> 	ren[5]->SetViewport(.68667 ,  .35333 ,   .98 ,     .64667);
> 	ren[6]->SetViewport(0.02   ,    .68667  , .31333 , .98);
> 	ren[7]->SetViewport(.35333 ,  .68667 ,  .64667 , .98);
> 	ren[8]->SetViewport(.68667,   .68667 ,   .98   ,  .98);
>
> 	renwin->Render();
>
>
> On Thu, 9 Dec 2004 22:57:37 -0500, Mathieu Malaterre
> <mathieu.malaterre at kitware.com> wrote:
>> Kingaza
>>
>>> hi all, i am a new guy in vtk, now i am going to write an
>>> visualization application, but it is difficult to read dicom file in
>>> vtk.
>>
>> What do you mean 'it is difficult' ?
>> - Does the program crash ?
>> - The image appears black ?
>> - Does the program hangs ?
>>
>> - Which DICOM reader are you using ?
>> vtkDICOMImageReader only read non compress DICOM images.
>> vtkGDCMReader read a lot more image, but this is not part of VTK:
>>
>> http://www.creatis.insa-lyon.fr/Public/Gdcm/
>>
>> There might be some other option I don't know of.
>>
>> HTH
>> Mathieu
>> BTW ITK (http://www.itk.org) integrate gdcm version 0.6
>>
>>
> _______________________________________________
> 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
>
>
Yan Pingkun
Vision & Image Processing Lab
National University of Singapore
Lab: +65 6874 8035
HP:  +65 9094 6256




More information about the vtkusers mailing list