About window width and window level and display?

How to get the window width and window level of DICOM file, and set VR data to display only bones according to the window width and window level.

This depends on how you get the DICOM data into VTK. The vtkDICOMReader provides CT data in Hounsfield units, so you can apply a bone window directly to the data. For bone, you can try W=2000 and L=500 as a starting point, and then fine-tune the values to get exactly the visualization that you want.

The WindowWidth and WindowCenter attributes that are stored in the DICOM file are probably not the ideal values for in VR. They will never show “only bone,” because that is not their purpose. They will always show some soft tissue, too.

Sorry! I do not know how to apply a bone window(or WL) to the 3D data? Can you tell me? thanks!

What mapper (or viewer) are you using to display the data? Different mappers use different methods to set WL.

If you use vtkImageMapToColors, then create a vtkLookupTable and set the Range:
vtkLookupTable::SetRange(L - W/2.0, L + W/2.0)

For vtkImageSliceMapper, use vtkImageProperty::SetColorWindow(W) and SetColorLevel(L).

For volume rendering, it is more complicated, but you can create a ColorTransferFunction and an OpacityTransferFunction for the WL.