<html><head><meta http-equiv="content-type" content="text/html; charset=GB2312"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 微软雅黑; color: rgb(0, 0, 0); line-height: 1.5; }body { font-size: 10.5pt; font-family: 微软雅黑; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span></span>Dear Cory</div><div><br></div><div>       I am sorry, but those code doesn't work. </div><div><img src="cid:_Foxmail.1@96ec3b24-9d57-747f-a17f-06ade71d1bc0" border="0"></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">    </span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">    </span><span style="background-color: rgba(0, 0, 0, 0); font-size: 10.5pt; line-height: 1.5;">   And the complete code is :</span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">void main()<br>{<br>  <span style="white-space: pre;"> </span>vtkSmartPointer<vtkDICOMImageReader> reader = vtkSmartPointer<vtkDICOMImageReader>::New();<br> <span style="white-space: pre;">      </span>reader->SetDirectoryName("G:\\Perfusion Project\\Perfusion_MIP\\MIP\\TimePhase\\Time2");<br> <span style="white-space: pre;"> </span>reader->SetDataByteOrderToBigEndian();<br> <span style="white-space: pre;">  </span>reader->Update();<br><br><br><span style="white-space: pre;"> </span>vtkSmartPointer<vtkImageShiftScale> shift = vtkSmartPointer<vtkImageShiftScale>::New();<br><span style="white-space: pre;">       </span>shift->SetInputConnection(reader->GetOutputPort());<br><span style="white-space: pre;">        </span>shift->SetOutputScalarTypeToUnsignedShort();<br><span style="white-space: pre;">  </span>shift->Update();<br><br><span style="white-space: pre;">    </span>vtkSmartPointer<vtkImageReslice> reslice = vtkSmartPointer<vtkImageReslice>::New();<br><span style="white-space: pre;">   </span>reslice->SetInputData(shift->GetOutput());<br><span style="white-space: pre;"> </span>reslice->SetOutputDimensionality(3);<br><span style="white-space: pre;">  </span>reslice->Update();<br><span style="white-space: pre;">    </span><br><span style="white-space: pre;"> </span>vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New();<br><span style="white-space: pre;">   </span>image=reslice->GetOutput();<br><br><span style="white-space: pre;"> </span>vtkSmartPointer<vtkImageWriter> writer = vtkSmartPointer<vtkImageWriter>::New();<br><span style="white-space: pre;">      </span>writer->SetInputData(image);<br><span style="white-space: pre;">  </span>writer->SetFileName("C:\\Users\\zhq\\Desktop\\VolumeData.vtk");<br><span style="white-space: pre;">     </span>writer->Update();<br><br><span style="white-space: pre;">   </span>vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();<br><span style="white-space: pre;">       </span>vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();<br><span style="white-space: pre;">    </span>vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();<br><span style="white-space: pre;">  </span>vtkSmartPointer<vtkInteractorStyleTrackballCamera> style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();<br><br><span style="white-space: pre;">       </span>renWin->AddRenderer(ren);<br><span style="white-space: pre;">     </span>renWin->SetInteractor(iren);<br><span style="white-space: pre;">  </span>iren->SetInteractorStyle(style);<br><br><span style="white-space: pre;">    </span>vtkSmartPointer<vtkPiecewiseFunction> opacityTransferFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();<br><span style="white-space: pre;"> </span>opacityTransferFunction->AddPoint(0,1200);<br><span style="white-space: pre;">    </span>opacityTransferFunction->AddPoint(1200,0.4);<br><span style="white-space: pre;">  </span>opacityTransferFunction->AddPoint(2000,0.2);<br><br><span style="white-space: pre;">        </span>/*vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction = vtkSmartPointer<vtkColorTransferFunction>::New();<br><span style="white-space: pre;"> </span>colorTransferFunction->AddRGBPoint(0,0,0.5,0);<br><span style="white-space: pre;">        </span>colorTransferFunction->AddRGBPoint(60,1,0,0);<br><span style="white-space: pre;"> </span>colorTransferFunction->AddRGBPoint(255,0.8,0.8,0.8);*/<br><br><span style="white-space: pre;">      </span>vtkSmartPointer<vtkDiscretizableColorTransferFunction > colorTransferFunction = vtkSmartPointer<vtkDiscretizableColorTransferFunction >::New(); <br><span style="white-space: pre;">       </span>colorTransferFunction->AddRGBPoint(0,0,0.5,0); <br><span style="white-space: pre;">  </span>colorTransferFunction->AddRGBPoint(60,1,0,0); <br><span style="white-space: pre;">   </span>colorTransferFunction->AddRGBPoint(255,0.8,0.8,0.8);<br><span style="white-space: pre;">  </span>colorTransferFunction->SetScalarOpacityFunction(opacityTransferFunction);<br><span style="white-space: pre;">     </span>colorTransferFunction->EnableOpacityMappingOn();<br><br><span style="white-space: pre;">    </span>vtkSmartPointer<vtkVolumeProperty> volumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();<br><span style="white-space: pre;">        </span>volumeProperty->SetColor(colorTransferFunction);<br><span style="white-space: pre;">      </span>volumeProperty->SetScalarOpacity(opacityTransferFunction);<br><span style="white-space: pre;">    </span>volumeProperty->ShadeOn();<br><span style="white-space: pre;">    </span>volumeProperty->SetInterpolationTypeToLinear();<br><span style="white-space: pre;">       </span>volumeProperty->SetAmbient(0.2);<br><br><span style="white-space: pre;">    </span>vtkSmartPointer<vtkVolumeRayCastMIPFunction> mipRayCastFunction = vtkSmartPointer<vtkVolumeRayCastMIPFunction>::New();<br><span style="white-space: pre;">        </span>vtkSmartPointer<vtkVolumeRayCastCompositeFunction> compositeFunction = vtkSmartPointer<vtkVolumeRayCastCompositeFunction>::New();<br><span style="white-space: pre;">     </span>vtkSmartPointer<vtkVolumeRayCastMapper> volumeMapper = vtkSmartPointer<vtkVolumeRayCastMapper>::New();<br><br><span style="white-space: pre;">      </span>volumeMapper->SetVolumeRayCastFunction(compositeFunction);<br><span style="white-space: pre;">    </span>volumeMapper->SetInputData(image);<br><br><span style="white-space: pre;">  </span>vtkSmartPointer<vtkVolume> volume = vtkSmartPointer<vtkVolume>::New();<br><span style="white-space: pre;">        </span>volume->SetMapper(volumeMapper);<br><span style="white-space: pre;">      </span>volume->SetProperty(volumeProperty);<br><br><span style="white-space: pre;">        </span>ren->AddVolume(volume);<br><span style="white-space: pre;">       </span>ren->SetBackground(1,1,1);<br><span style="white-space: pre;">    </span>renWin->Render();<br><span style="white-space: pre;">     </span>iren->Initialize();<br><span style="white-space: pre;">   </span>iren->Start();<br>}</span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">    </span></div><div><span style="color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">    </span><span style="background-color: rgba(0, 0, 0, 0); font-size: 10.5pt; line-height: 1.5;">    Thank you very much!</span></div><div><span style="background-color: rgba(0, 0, 0, 0); font-size: 10.5pt; line-height: 1.5;"><br></span></div><div><span style="background-color: rgba(0, 0, 0, 0); font-size: 10.5pt; line-height: 1.5;">ZhangQiang</span></div>
<div><br></div><hr style="WIDTH: 210px; HEIGHT: 1px" color="#b5c4df" size="1" align="left">
<div><span><div style="MARGIN: 10px; FONT-FAMILY: verdana; FONT-SIZE: 10pt"><br></div></span></div>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;"><div> </div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:cory.quammen@kitware.com">Cory Quammen</a></div><div><b>Date:</b> 2015-07-10 00:42</div><div><b>To:</b> <a href="mailto:15891495523@126.com">15891495523@126.com</a></div><div><b>CC:</b> <a href="mailto:vtkusers@vtk.org">vtkusers</a></div><div><b>Subject:</b> Re: [vtkusers] A question about displaying Image using VTK</div></div></div><div><div class="FoxDiv20150710111330435901">
<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: 0px 0px 0px 0.5em; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: 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@7049523a-942f-3525-866a-34507c0a5ffb" 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>
<div class="netease-attDown" style="width: 430px; height: auto; background-color: rgb(246, 249, 252); border: 1px solid rgb(197, 210, 218); padding: 12px; line-height: 160%; font-size: 12px; white-space: nowrap; font-family: Verdana;">
        <div class="netease-notice" style="padding-bottom: 5px; white-space: normal;"><img src="http://mimg.127.net/xm/all/attpreview/img/ico_notice.gif" alt="提示图标" style="vertical-align:middle"> 邮件带有附件预览链接,若您转发或回复此邮件时不希望对方预览附件,建议您手动删除链接。</div>
        <div class="netease-attDown-tit" style="color: rgb(160, 160, 160);">共有 <strong style="color: rgb(0, 128, 0);">1</strong> 个附件</div>
        
                <dl style="margin: 0px; padding: 0px; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
                        <dt title="InsertPic_.jpg" style="margin: 8px 0px 0px; padding: 0px; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; color: rgb(51, 51, 51);">InsertPic_.jpg<span class="info" style="color: rgb(153, 153, 153); font-weight: normal;">(99K)</span></dt>
                        <dd style="margin: 0px; padding: 0px; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
                                <a href="http://preview.mail.126.com/xdownload?filename=InsertPic_.jpg&mid=1tbi5RkySFUw0mtsvwAAsJ&part=3&sign=fb3a712652d3c40c438e729aae49e4be&time=1436460555&uid=15891495523%40126.com" target="_blank" style="color: rgb(6, 105, 178);">极速下载</a>
                                <a href="http://preview.mail.126.com/preview?mid=1tbi5RkySFUw0mtsvwAAsJ&part=3&sign=fb3a712652d3c40c438e729aae49e4be&time=1436460555&uid=15891495523%40126.com" target="_blank" style="color: rgb(6, 105, 178);">在线预览</a>
                        </dd>
                </dl>
        
</div>
</div></div></blockquote>
</body></html>