Hi, all <br><br>I use vtkDICOMImageReader read Medical image of DICOM format, and then use vtkDICOMImageReader::SetDataScalarTypeToUnsignedShort() to change the datatype,<br><br>but when I use vtkVolumeRayCastMapper, i got the follow message:
<br>vtkVolumeRayCastMapper(0x02AA83A8): Cannot volume render data of type short, only unsigned char or unsigned short.<br><br>It seems the function SetDataScalarTypeToUnsignedShort() did not work. why? and how can i change the data type into unsinged char? or some other methods to use vtkVolumeRayCastMapper?
<br><br>my code is,<br><br>                pvtkDICOMImagereader = vtkDICOMImageReader::New();<br>                pvtkDICOMImagereader->SetDirectoryName(directoryname);<br>                pvtkDICOMImagereader->SetDataScalarTypeToUnsignedShort();<br>                pvtkDICOMImagereader->Update();
<br><br>                vtkPiecewiseFunction *opacityTFunc=vtkPiecewiseFunction::New();<br>                opacityTFunc->AddPoint(0.0, 0.0);<br>                opacityTFunc->AddPoint(scalar1, alphar1);<br>                opacityTFunc->AddPoint(scalar2, alphar2);<br>                opacityTFunc->AddPoint(scalar3, alphar3);
<br>                opacityTFunc->AddPoint(scalar4, alphar4);<br><br><br>                vtkVolumeProperty *volumeProperty=vtkVolumeProperty::New();<br>                // volumeProperty->SetColor(colorTFunc);<br>                volumeProperty->SetScalarOpacity(opacityTFunc);
<br>                volumeProperty->SetInterpolationTypeToLinear();<br>                volumeProperty->SetAmbient(1.8);//0.2<br>                volumeProperty->SetDiffuse(1.0);<br>                volumeProperty->SetSpecular(0.7);//0.2<br>                volumeProperty->SetSpecularPower(30);
<br>                volumeProperty->ShadeOn();<br><br>                //<br>                vtkVolumeRayCastMIPFunction <br>                 *compositeFunction=vtkVolumeRayCastMIPFunction::New();<br><br><br>                vtkVolumeRayCastMapper *volumeMapper=vtkVolumeRayCastMapper::New();
<br>                volumeMapper->SetInput(this->reader->GetOutput());<br>                volumeMapper->SetVolumeRayCastFunction(compositeFunction);<br>                volumeMapper->SetNumberOfThreads(3);<br>                cerr<<volumeMapper->GetNumberOfThreads();
<br><br>                vtkVolume *volume=vtkVolume::New();<br>                volume->SetMapper(volumeMapper);<br>                volume->SetProperty(volumeProperty);<br>                this->pvtkRenderer->AddVolume(volume);<br><br><br clear="all"><br>-- <br>veelion