[vtkusers] Fwd: help:how to get 2D image by maximum intensity projection?
Italo Ribeiro
italo.ribeiro at gmail.com
Fri Sep 10 11:32:21 EDT 2010
---------- Forwarded message ----------
From: Italo Ribeiro <italo.ribeiro at gmail.com>
Date: 2010/9/10
Subject: Re: [vtkusers] help:how to get 2D image by maximum intensity
projection?
To: 陆阳 <thuluyang at gmail.com>
Hi, my english is poor too.
I am use vtkImageViewer2 for see the DICOM images. I am use the code:
//read DICOM images
---------------------------------------------------------------------------------------------------------------------------
vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
reader->SetDirectoryName("C:/cranio");
reader->Update();
//create MIP projection
--------------------------------------------------------------------------------------------------------------------------
vtkImageCast *cast = vtkImageCast::New();
cast->SetInputConnection(reader->GetOutputPort());
cast->SetOutputScalarTypeToUnsignedChar();
//define range of values
vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New();
opacityTransferFunction->AddPoint( 150 , 0.0 );
opacityTransferFunction->AddPoint( 255 , 1.0 );
//Create a transfer function mapping scalar value to color (grey)
vtkPiecewiseFunction *grayTransferFunction =
vtkPiecewiseFunction::New();
grayTransferFunction->AddSegment( 0 , 0.0 , 255 , 1.0 );
// Create a set of properties for mip
vtkVolumeProperty *mipProperty;
mipProperty = vtkVolumeProperty::New();
mipProperty->SetScalarOpacity( opacityTransferFunction );
mipProperty->SetColor( grayTransferFunction );
mipProperty->SetInterpolationTypeToLinear();
vtkVolumeRayCastMIPFunction* mipFunction =
vtkVolumeRayCastMIPFunction::New();
mipFunction->SetMaximizeMethodToOpacity();
vtkVolumeRayCastMapper* volumeMapper = vtkVolumeRayCastMapper::New();
volumeMapper->SetVolumeRayCastFunction( mipFunction );
volumeMapper->SetInput( cast->GetOutput() );
vtkVolume* volume = vtkVolume::New();
volume->SetMapper( volumeMapper );
volume->SetProperty( mipProperty );
vtkRenderer *renderer1 = vtkRenderer::New();
renderer1->SetViewport(0.5, 0.5, 1.0, 1.0);
renderer1->SetBackground(0.0, 0.0, 0.0);
renderWindow->AddRenderer(renderer1);
renderer1->AddViewProp(volume);
//create image viewer
--------------------------------------------------------------------------------------------------------------------------------
vtkImageViewer2 *viewer = vtkImageViewer2::New();
viewer->SetInput(reader->GetOutput());
viewer->GetRenderer()->SetViewport(0.0, 0.5, 0.5, 1.0);
renderWindow->AddRenderer(viewer->GetRenderer());
viewer->OffScreenRenderingOn(); //dont show window of load images
int VolData_Images = viewer->GetSliceMax();
viewer->SetSlice(50); //slice showed
The values of pixel image i get:
short* tuple = (short*)image->GetScalarPointer(image_coordinate);
I hope this code help you. I dont know what i doing bad. I want MIP values
of pixel.
2010/9/10 陆阳 <thuluyang at gmail.com>
>
> hello,sorry to interupt you .
> but i have a really important question.i am asking you for help.
> i am a new learner of vtk.
> recently,i am using vtk to do 3d reconstruction.
> i am using mip(maximum intenstity projection ) to do this.
> first reading some silces of ct dicom image,then do the projection.
> as you know vtk is using pipeline ,we can only get 3d volume.
> but what i want is the 2d image by MIP.
> i dont know if i make myself understood by you? my english is poor.
> here is the main code:
> //read the dicoms
> vtkDICOMImageReader *volumeReader = vtkDICOMImageReader::New();
> volumeReader->SetDirectoryName("C:/mrdata");
> vtkImageShiftScale *scale=vtkImageShiftScale::New();
>
>
> scale->SetInput(volumeReader->GetOutput());
> scale->SetOutputScalarTypeToUnsignedChar();
> scale->Update();
>
>
> vtkVolumeRayCastMIPFunction *MIP = vtkVolumeRayCastMIPFunction::New();
> vtkVolumeRayCastMapper *RaycastMapper = vtkVolumeRayCastMapper::New();
> RaycastMapper->SetVolumeRayCastFunction(MIP);
> RaycastMapper->SetInput(scale->GetOutput());
>
>
> here is the case, where i can get the 2d image i want?
> i couldnot find any interface.but i think the image should be the output
> of RaycastMapper?
> the pity is i cant find any output of RaycastMapper.
> could you give me some suggestions?
> --
> 陆阳
> 清华大学医学院生物医学工程系
> Yang Lu
> Department of Biomedical Engineering,
> School of Medicine, Tsinghua University
> 电话/Tel:+86-010-51532315
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
--
Ítalo Mendes
ogre.irados.org
--
Ítalo Mendes
ogre.irados.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100910/bcd887e4/attachment.htm>
More information about the vtkusers
mailing list