This is my MIP code and it works fine for me. Your problem might be you are using a vtkColorTransferFunction when another vtkPieceWiseFunction should be enough. Hope this helps :)<br><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
opacityTransferFunction->AddPoint( 20 , 0.0 );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> opacityTransferFunction->AddPoint( 255 , 1.0 );</span>
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // Create a transfer function mapping scalar value to color (grey)</span>
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> vtkPiecewiseFunction *grayTransferFunction = vtkPiecewiseFunction::New();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> grayTransferFunction->AddSegment( 0 , 0.0 , 255 , 1.0 );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
// Create a set of properties for mip</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> vtkVolumeProperty *mipProperty;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> mipProperty = vtkVolumeProperty::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
mipProperty->SetScalarOpacity( opacityTransferFunction );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> mipProperty->SetColor( grayTransferFunction );
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> mipProperty->SetInterpolationTypeToLinear();</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> // creem la funció del raig MIP, en aquest cas maximitzem l'opacitat, si fos Scalar value, ho faria pel valor</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vtkVolumeRayCastMIPFunction* mipFunction = vtkVolumeRayCastMIPFunction::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
mipFunction->SetMaximizeMethodToOpacity();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
vtkVolumeRayCastMapper* volumeMapper = vtkVolumeRayCastMapper::New();</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
volumeMapper->SetVolumeRayCastFunction( mipFunction );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> volumeMapper->SetInput( m_imageCaster->GetOutput() );
</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
vtkVolume* volume = vtkVolume::New();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> volume->SetMapper( volumeMapper );</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> volume->SetProperty( mipProperty );</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
m_renderer->AddViewProp( volume );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> m_renderer->Render();</span><br><br><div><span class="gmail_quote">
2006/10/2, Michele Marco <<a href="mailto:michelegr@alice.it">michelegr@alice.it</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff">
<div><font face="Arial" size="2">I'm italian Student and i need help for setting MIP
in VTK . I use vtk <font size="2">vtkVolumeRayCastMIPFunction class to
realize MIP but i have some problem to configure "<font size="2">vtkPiecewiseFunction" and "<font size="2">vtkColorTransferFunction" .The
code is :</font></font></font></font></div>
<div>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: green;" lang="EN-GB">//
Create the renderers, render window, and interactor</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span> </span>vtkRenderWindow *renWin =
vtkRenderWindow::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span> </span>vtkRenderer *ren =
vtkRenderer::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span> </span>vtkRenderWindowInteractor *iren =
vtkRenderWindowInteractor::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span>renWin->AddRenderer(ren);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span> </span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"> </span></p>
<p style="margin: 0cm 0cm 0pt 12pt;"><span style="font-size: 10pt;" lang="EN-GB">vtkInteractorStyleTrackballCamera
*aTrackBallCamera = <span> </span>vtkInteractorStyleTrackballCamera::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span>iren->SetInteractorStyle(aTrackBallCamera);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span>iren->SetRenderWindow(renWin);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"> </span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">vtkDICOMImageReader
*reader= vtkDICOMImageReader::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">reader->SetDirectoryName("C:/tac2");</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">reader->Update();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: green;"> </span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">vtkImageCast
*cast = vtkImageCast::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">cast->SetInputConnection(reader->GetOutputPort());</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">cast->SetOutputScalarTypeToUnsignedChar();<span style="color: green;"></span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: green;" lang="EN-GB"> </span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">vtkPiecewiseFunction
*opacityTransferFunction = vtkPiecewiseFunction::New();<span style="color: green;"></span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">opacityTransferFunction->AddSegment(0,
0.1, 255, 0.9);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"> </span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">vtkColorTransferFunction
*colorTransferFunction = vtkColorTransferFunction::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: green;" lang="EN-GB">colorTransferFunction->AddRGBPoint(<span> </span>0, 1.0, 0.0, 0.0
);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: green;" lang="EN-GB">colorTransferFunction->AddRGBPoint(<span> </span>64, 1.0, 1.0, 0.0
);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: green;" lang="EN-GB">colorTransferFunction->AddRGBPoint(
128, 0.0, 1.0, 0.0 );</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: green;" lang="EN-GB">colorTransferFunction->AddRGBPoint(
192, 0.0, 1.0, 1.0 );</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">colorTransferFunction->AddRGBPoint(
255, 0.1, 0.5, 1.0 );</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"> </span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span><span style="color: green;"><span> </span></span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">vtkVolumeProperty
*volumeProperty = vtkVolumeProperty::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">volumeProperty->SetColor(colorTransferFunction);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">volumeProperty->SetScalarOpacity(opacityTransferFunction);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">volumeProperty->SetInterpolationTypeToLinear();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">vtkVolumeRayCastMIPFunction
*compositeMipFunction = vtkVolumeRayCastMIPFunction::New();<span style="color: green;"></span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">compositeMipFunction->SetMaximizeMethodToScalarValue();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: green;" lang="EN-GB"> </span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: green;" lang="EN-GB"> </span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">vtkVolumeRayCastMapper
*volumeRaycastMapper = vtkVolumeRayCastMapper::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span>volumeRaycastMapper->SetVolumeRayCastFunction(compositeMipFunction);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span>volumeRaycastMapper->SetInputConnection(cast->GetOutputPort());</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span></span><span style="font-size: 10pt;">vtkVolume *volume =
vtkVolume::New();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;"><span>
</span>volume->SetMapper(volumeRaycastMapper);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;"><span>
</span>volume->SetProperty(volumeProperty);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;"><span>
</span>volume->VisibilityOn();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;"><span>
</span>volume->Update();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;"><span>
</span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">ren->AddVolume(volume);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">renWin->SetSize(500,500);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">ren->ResetCamera();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">ren->GetActiveCamera()->Zoom(1.5);</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><span>
</span></span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">iren->Initialize();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">renWin->Render();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB">iren->Start();</span></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"></span> </p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt;" lang="EN-GB"><font size="4">HELP ME
PLEASE!!!!!!!!!!!</font></span></p></div></div>
<br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers
</a><br><br><br></blockquote></div><br>