<div dir="ltr"><div>I have a 16bit cube data that has various segments of unique grey levels. I want to visualize each of these segments selectively using a slider (just the surface visualization is good enough) . This slider ranges from the min to the max of the grey levels in that cube.</div>
<div><br></div><div>I expected isosurfaces to do that job well. But it seems any level of isovalue behaves somewhat like thresholding and essentially divides the grey levels in 2 parts - the ones lower than the isovalue and the ones higher than the isovalue. This means that all of the segments higher than the selected would get 'iso-surfaced' (if I may say so!) as well (as in attached image).</div>
<div><br></div><div>How can I view just one of the segments at a time, interactively?</div><div>Ideally in the image, I should be seeing just 1 of those structures at a time (it currently shows 3).</div><div><br></div><div>
here's part of the code:</div><div><br></div><div><br></div><div>// short data</div><p>vtkSmartPointer<vtkImageReader> v16 = vtkSmartPointer<vtkImageReader>::New();</p><div>v16->SetFileName(argv[2]);<br>
v16->SetFileDimensionality(3);<br>v16->SetDataScalarTypeToUnsignedShort();<br>v16->SetDataByteOrderToLittleEndian();<br>v16->SetNumberOfScalarComponents(1);<br>v16->SetDataExtent(0,width-1, 0,height-1, 0,depth-1);<br>
v16->SetDataSpacing (1.0, 1.0, 1.0);<br>v16->Update();</div><div><br></div><div>double range[2];<br>v16->GetOutput()->GetPointData()->GetScalars()->GetRange(range);<br>std::cout << "Range: " << range[0] << " , " << range[1] << std::endl;<br>
double midpoint = (range[1]-range[0])/2;<br></div><p>//Now build a LUT<br>vtkSmartPointer<vtkLookupTable> lookupTable = vtkSmartPointer<vtkLookupTable>::New();<br>lookupTable->SetNumberOfTableValues(range[1]);<br>
lookupTable->SetTableRange(range[0], range[1]);<br>// Firstly, set all transparent<br>for(int i=range[0]; i<range[1]; ++i)<br>{<br>lookupTable->SetTableValue( i, .66, .92, .33, 0.0 ); //some shade of green but transparent<br>
}<br>// Make that 1 value corresponding to slider visible<br>lookupTable->SetTableValue( (int) midpoint, .66, .92, .33, 1.0 ); //same color as above, but visible<br>lookupTable->Build();</p><div>//Usual steps as in Medical3 example<br>
vtkSmartPointer<vtkContourFilter> Extractor =<br>vtkSmartPointer<vtkContourFilter>::New();<br>Extractor->SetInputConnection( v16->GetOutputPort());<br>Extractor->SetNumberOfContours(1);</div><div>// set an isovalue. in this case, the midpoint of the greyscales<br>
Extractor->GenerateValues(1, midpoint, midpoint);<br>Extractor->Update();</div><p>vtkSmartPointer<vtkPolyDataNormals> Normals =<br>vtkSmartPointer<vtkPolyDataNormals>::New();<br>Normals->SetInputConnection(grainExtractor->GetOutputPort());<br>
Normals->ReleaseDataFlagOn();<br>Normals->SetFeatureAngle(60.0);<br>Normals->Update();</p><p>vtkSmartPointer<vtkStripper> Stripper =<br>vtkSmartPointer<vtkStripper>::New();<br>Stripper->SetInputConnection(grainNormals->GetOutputPort());<br>
Stripper->ReleaseDataFlagOn();<br>Stripper->Update();</p><p>// An addition to Medical 3 example: Provide LUT to Mapper<br>vtkSmartPointer<vtkPolyDataMapper> Mapper =<br>vtkSmartPointer<vtkPolyDataMapper>::New();<br>
Mapper->SetInputConnection(grainStripper->GetOutputPort());<br>Mapper->ReleaseDataFlagOn();<br>Mapper->ScalarVisibilityOn();<br>Mapper->SetScalarRange(lookupTable->GetRange());<br>Mapper->SetLookupTable(lookupTable);<br>
Mapper->Update();</p><div>vtkSmartPointer<vtkActor> Actor =<br>vtkSmartPointer<vtkActor>::New();<br>Actor->SetMapper(grainMapper);<br>Actor->GetProperty()->SetDiffuseColor(.66, .92, .33);<br>Actor->GetProperty()->SetSpecular(.3);<br>
Actor->GetProperty()->SetSpecularPower(20);<br>Actor->GetProperty()->SetOpacity(1.0);</div><div><br></div><div><br></div><div>// Rest of the code handles a slider that tries to change the isovalue</div><div>// But doesn't reflect the change :(</div>
<div><br></div><div>What's wrong in my approach of using vtkLookupTable with vtkContourFilter?</div><div>Is there an alternate?</div><div><br></div><div><br></div><div>best regards,</div><div>Divya Rathore</div></div>