<div dir="ltr">Instead of using a vtkColorTransferFunction, try using a vtkDiscretizableColorTransferFunction and setting the opacity function via SetScalarOpacityFunction(), e.g.<div><br></div>vtkSmartPointer<vtkDiscretizableColorTransferFunction > colorTransferFunction = vtkSmartPointer<vtkDiscretizableColorTransferFunction >::New(); <br>colorTransferFunction->AddRGBPoint(0,0,0.5,0); <br>colorTransferFunction->AddRGBPoint(60,1,0,0); <br>colorTransferFunction->AddRGBPoint(255,0.8,0.8,0.8);<div>colorTransferFunction->SetScalarOpacityFunction(opacityTransferFunction);</div><div><br></div><div>then enable opacity mapping with</div><div><br></div><div>colorTransferFunction->EnableOpacityMappingOn();</div><div><br></div><div>HTH,</div><div>Cory</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 9, 2015 at 9:51 AM, <a href="mailto:15891495523@126.com">15891495523@126.com</a> <span dir="ltr"><<a href="mailto:15891495523@126.com" target="_blank">15891495523@126.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
<div><span></span><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">Dear all </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">    I feel confused when display a CT image using VTK. How can I make those black and gray part in the following picture invisible ? </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">    The key part of my code is : </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">vtkSmartPointer<vtkPiecewiseFunction> opacityTransferFunction = vtkSmartPointer<vtkPiecewiseFunction>::New(); </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">        opacityTransferFunction->AddPoint(0,1200); </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">        opacityTransferFunction->AddPoint(1200,0.4); </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">        opacityTransferFunction->AddPoint(2000,0.2); </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">        vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction = vtkSmartPointer<vtkColorTransferFunction>::New(); </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">        colorTransferFunction->AddRGBPoint(0,0,0.5,0); </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">        colorTransferFunction->AddRGBPoint(60,1,0,0); </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">        colorTransferFunction->AddRGBPoint(255,0.8,0.8,0.8); </span></div><div><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><br></span></div><div><img src="cid:_Foxmail.1@f7c875ca-37c8-8895-8f54-dad40a5eb5ab" border="0"></div><div><br></div><div><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">Thank you in advanced! </span><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><br style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal">ZhangQiang</span></div><div><span style="font-family:Verdana,Geneva,Helvetica,Arial,sans-serif;font-size:13.4399995803833px;line-height:normal"><br></span></div>
<div><br></div><hr style="width:210px;min-height:1px" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN:10px;FONT-FAMILY:verdana;FONT-SIZE:10pt"><br></div></span></div>
</div><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Cory Quammen<br>R&D Engineer<br>Kitware, Inc.</div>
</div>