[vtkusers] How do i port an image from ITK to VTK

Prename Surname bsd.diverse at gmail.com
Wed Oct 11 10:07:54 EDT 2006


Hello Brian.
I have tried to do what you said, and it makes good sense. I think i almost
got i working, but i still have a doubt about how exactly i can connect the
itk::ImageToVTKImageFilter to the vtkVolumeRayCastMapper.
It seems that  ImageToVTKImageFilter->GetOutput(...) returns a vtkImageData,
and
vtkVolumeRayCastMapper->SetInputConnection(...) only accepts a
vtkAlgorithmOutput object.

So how do i do the final mapping? I really hope you can help me, or any
others can.

Many regards

Here is the code:

int main( int , char * argv[])
{
 typedef unsigned char PixelType;
 const unsigned int Dimension=3;

 typedef itk::Image<PixelType,Dimension> ImageType;
 typedef itk::ImageFileReader<ImageType> ReaderType;
 typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;

 ReaderType::Pointer reader = ReaderType::New();
 ConnectorType::Pointer connector = ConnectorType::New();

 reader->SetFileName("D:\\skole\\thesis\\Data\\KDIGWKFN\\ANALYZE\\KDIGWKFN_mpr_pip.img");
 connector->SetInput(reader->GetOutput());//In connector lies now the
imagedata. Retrieve it by calling GetOutput()

 vtkStructuredPointsReader *vtkReader=vtkStructuredPointsReader::New();


 //Create transfer mapping scalar value to color
 vtkPiecewiseFunction *opacityTransferfunction=vtkPiecewiseFunction::New();
 opacityTransferfunction->AddPoint(20.,0.0);
 opacityTransferfunction->AddPoint(255.,0.2);

 vtkColorTransferFunction
*colorTransferFunction=vtkColorTransferFunction::New();
 colorTransferFunction->AddRGBPoint(0.0,0.0,0.0,0.0);
 colorTransferFunction->AddRGBPoint(64.0,1.0,0.0,0.0);
 colorTransferFunction->AddRGBPoint(128.0,0.0,0.0,1.0);
 colorTransferFunction->AddRGBPoint(192.0,0.0,1.0,0.0);
 colorTransferFunction->AddRGBPoint(255.0,0.0,0.2,0.0);

 vtkVolumeProperty *volumeProperty=vtkVolumeProperty::New();
 volumeProperty->SetColor(colorTransferFunction);
 volumeProperty->SetScalarOpacity(opacityTransferfunction);

 vtkVolumeRayCastCompositeFunction
*compositeFunction=vtkVolumeRayCastCompositeFunction::New();
 vtkVolumeRayCastMapper *volumeMapper=vtkVolumeRayCastMapper::New();
 volumeMapper->SetVolumeRayCastFunction(compositeFunction);

 volumeMapper->SetInputConnection(connector->GetOutput()); //This i cannot
do. What should i do instead?

2006/10/11, Brian Chacko <brianchacko at yahoo.com>:
>
> Hello!
> I suggest you go through the link given below. It gives basics of using
> ITK and visualizing in VTK.
> http://www.itk.org/CourseWare/Training/GettingStarted-II.pdf
>
> [P.N The header file itkImageToVTKImageFilter.h is not available as it is,
> when you download the ITK software source. Download
> InsightApplications-2.8.1.zip<http://prdownloads.sourceforge.net/itk/InsightApplications-2.8.1.zip?download>.
> It is available in the ITK download page. Include the header file with the
> .cxx file in the VTK 5.0\IO\  (or any sub folder of vtk 5.0 which
> contains headers and source files). Remember to include the appropriate
> library file in your CMakeLists.txt)].
>
> To  visualize volume view, try out the volume example in VTK folder
> Directory path is     "\VTK
> 5.0\Examples\VolumeRendering\Tcl\SimpleRayCast.tcl".
>
> Regards
> Brian
> ** **
> **
> *Prename Surname <bsd.diverse at gmail.com>* wrote:
>
>  Hello
> I am reading files from ANALYZE format in ITK. I do processing of the
> image, and then i want to visualize it in VTK.
> So  my question is how i get the data fra ITK to VTK, and is it then
> difficult to show a volumne view of the data in VTK?
> A codeexample would be very nice. Thank you very much
>
> Best of regards
> _______________________________________________
> 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
>
>
>  ------------------------------
> How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call
> rates.
> <http://us.rd.yahoo.com/mail_us/taglines/postman8/*http://us.rd.yahoo.com/evt=39663/*http://voice.yahoo.com>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061011/8a78904c/attachment.htm>


More information about the vtkusers mailing list