Bill, thanks very much ! <br>Here are the all related codes:<br>vtkSmartPointer<vtkBMPReader> m_read = vtkSmartPointer<vtkBMPReader>::New();<br>m_read->SetFilePrefix("C:/Data/brain/TCVH_");//<br>m_read->SetFilePattern("%s%d.bmp"); //<br>
m_read->Allow8BitBMPOn();<br>m_read->SetDataByteOrderToLittleEndian();<br>m_read->SetFileNameSliceOffset(5);//<br>m_read->SetFileNameSliceSpacing(1);//<br>m_read->SetNumberOfScalarComponents(3);//<br>m_read->SetDataOrigin(0.0,0.0,0.0);//<br>
m_read->SetDataSpacing(0.167*4,0.167*4,1);//<br>m_read->SetDataExtent(0,299,0,345,1300,1320);//<br>m_read->Update();<br><br>vtkSmartPointer<vtkDiscreteMarchingCubes> cube =Â Â Â Â Â Â Â Â Â Â <br>Â Â vtkSmartPointer<vtkDiscreteMarchingCubes>::New() ;<br>
cube->SetInput((vtkDataObject*) m_read->GetOutput() );<br>cube->SetValue(0, 111);<br>cube->SetValue(1, 121);<br>cube->Update() ;<br><br>vtkSmartPointer<vtkDecimatePro>Â deci = vtkSmartPointer<vtkDecimatePro>::New();<br>
deci->SetInputConnection(cube->GetOutputPort());//<br>deci->SetTargetReduction(0.5); //<br>deci->PreserveTopologyOn(); //<br>deci->ReleaseDataFlagOn();<br><br>vtkSmartPointer<vtkWindowedSincPolyDataFilter> smoother= vtkSmartPointer<vtkWindowedSincPolyDataFilter>::New();<br>
smoother->SetInput(deci->GetOutput());<br>smoother->SetNumberOfIterations(30) ;<br>smoother->NonManifoldSmoothingOn();<br>smoother->NormalizeCoordinatesOn();<br>smoother->GenerateErrorScalarsOn() ;<br>smoother->Update();<br>
<br>vtkSmartPointer<vtkLookupTable> colorLookupTable= vtkSmartPointer<vtkLookupTable>::New();<br><br>colorLookupTable->SetTableRange(0, 122); <br>colorLookupTable->SetNumberOfTableValues(123);<br>colorLookupTable->Build();<br>
for (int i =0; i < 111; i++)<br>{<br>Â Â Â colorLookupTable->SetTableValue(i , i/255.0, i/255.0,i/255.0);<br>}<br>colorLookupTable->SetTableValue(111, 1,0,0,1);<br>for (int j = 112; j <120; j++)<br>{<br>Â Â Â colorLookupTable->SetTableValue(j , j/255.0, j/255.0, j/255.0);<br>
<br>}<br>colorLookupTable->SetTableValue(121, 0,1,1,1);<br>colorLookupTable->SetTableValue(122, 0,1,1,1);<br><br>vtkSmartPointer<vtkPolyDataNormals> triangleCellNormals = vtkSmartPointer<vtkPolyDataNormals>::New();<br>
triangleCellNormals->SetInput(smoother->GetOutput());<br>triangleCellNormals->ComputeCellNormalsOn();<br>triangleCellNormals->ComputePointNormalsOff();<br>triangleCellNormals->ConsistencyOn();<br>triangleCellNormals->AutoOrientNormalsOn();<br>
triangleCellNormals->Update() ;<br><br>vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();<br>mapper->SetInput(triangleCellNormals->GetOutput()); // #this is better for vis<br>
mapper->ScalarVisibilityOn() ;//#show colour <br>mapper->SetScalarRange(colorLookupTable->GetTableRange()); <br>mapper->SetScalarModeToUseCellData() ; //Â contains the label eg. 31<br>//mapper->SetScalarModeToUsePointData() ;//#the smoother error relates to the verts<br>
mapper->SetLookupTable(colorLookupTable);<br>Â <br>vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();<br>actor->SetMapper(mapper);<br><br>Waiting for suggestion, thanks in advance !<br><br>
Wenwu<br><br><br><br><div class="gmail_quote">On Fri, Apr 16, 2010 at 12:01 PM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The lookup table and mapper look OK to me. Can you attach the entire<br>
program if it is not too large?<br>
<br>
Bill<br>
<div><div></div><div class="h5"><br>
On Thu, Apr 15, 2010 at 9:00 PM, æœ±æ–‡æ¦ <<a href="mailto:cool.wenwu@gmail.com">cool.wenwu@gmail.com</a>> wrote:<br>
> hi all,<br>
><br>
>      I sent the message last night! However, no one responded ! So, i send<br>
> it again. Please forgive me, if it disrupts you!<br>
><br>
> I use vtkDiscreteMarchingCubes to reconstruct anatomy structure, and use the<br>
> vtkLookupTable to map the color. Now, i design the color map as follows:<br>
> gray value (111) to red,<br>
> gray value(121) to blue.<br>
> Other gray value I don't care.<br>
><br>
> Also, the parameter I set in SetValue() of vtkDiscreteMarchingCubes is:<br>
> SetValue(0, 111);<br>
> SetValue(1, 121);<br>
><br>
> Then i set the lookup table as follows:<br>
> vtkSmartPointer<vtkLookupTable> colorLookupTable=<br>
> vtkSmartPointer<vtkLookupTable>::New();<br>
> colorLookupTable->SetTableRange(0, 122); //<br>
> colorLookupTable->SetNumberOfTableValues(123);<br>
> colorLookupTable->Build();<br>
><br>
> for (int i =0; i < 111; i++)<br>
> {<br>
> Â Â Â colorLookupTable->SetTableValue(i , i/255.0, i/255.0,i/255.0); // i<br>
> don't care this loop<br>
> }<br>
> colorLookupTable->SetTableValue(111, 1,0,0,1); // this is essential for me<br>
> for (int j = 112; j <120; j++)<br>
> {<br>
> Â Â Â colorLookupTable->SetTableValue(j , j/255.0, j/255.0, j/255.0); // i<br>
> don't care this loop<br>
><br>
> }<br>
> colorLookupTable->SetTableValue(121, 0,0,1,1);<br>
> colorLookupTable->SetTableValue(122, 0,0,1,1);<br>
><br>
> vtkSmartPointer<vtkPolyDataMapper> mapper =<br>
> vtkSmartPointer<vtkPolyDataMapper>::New();<br>
> ...<br>
> mapper->ScalarVisibilityOn() ;//#show colour<br>
> mapper->SetScalarRange(colorLookupTable->GetTableRange());<br>
> mapper->SetScalarModeToUseCellData() ;<br>
> mapper->SetLookupTable(colorLookupTable);<br>
><br>
> The result of construction is that two structures whose gray value is 111<br>
> and 121 were reconstructed.<br>
> However, the color of these actors is the same- white.<br>
> Ccould anyone tell me why and give some suggestions?<br>
><br>
> Thanks<br>
> Wenwu<br>
</div></div>> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at:<br>
> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
><br>
><br>
</blockquote></div><br><br clear="all"><br>-- <br>ç¥<br>工作愉快,身体å¥åº·ï¼<br>