The Width and Level properties of an image are unusual, in that they are both stored as a part of the image, and are also transient DicomImage properties, regularly adjusted by users. This page explains the relationship between the persistent and transient values.
These are held in attributes 0028,1050 & 0028,1051 in the image. It is important to realise that they are optional attributes, and not every image contains these attributes. DicomObjects never changes the value of any attribute of a DicomImage or DicomDataSet unless this is specifically requested by the programmer. The values of the Width and Level attributes are no exception.
These are simply properties of a DicomImage and when changed cause the image (if in a DicomViewer’s collection) to be redisplayed with a revised mapping between pixel data and screen values.
The only relationship between the persistent and transient values is that the persistent values (if present) are used to initialise the transient values when the DicomImage is first created, or if the SetDefaultWindows method is used. At this time, the following procedure is used:
In general, DICOM image objects should not be altered once created and the behaviour of many PACS is unpredictable if modified images are sent to them, so changing the persistent data is discouraged, but of course this is sometimes necessary (and reasonable if you are the initial creator of an image!), in which case the values can be copied back into the image as follows:
Image.Attributes.Add(0x0028, 0x1050, Image.Level) Image.Attributes.Add(0x0028, 0x1051, Image.Width)
Image.DataSet.Add(0x0028, 0x1050, Image.Level); Image.DataSet.Add(0x0028, 0x1051, Image.Width); // or Image.DataSet.Add(DicomObjects.Enums.Keyword.WindowCenter, Image.Level); Image.DataSet.Add(DicomObjects.Enums.Keyword.WindowWidth, Image.Width);