Re: Algorithm for "Windows Center" and "Windows Width"



As David indicated, y represents the output display level. For an 8 bit display device, ymin = 0 (black), ymax = 255 (white) and everything else is shades of grey. For 16 bit pixel values, you have a potential range of 65536 values but you have only a display range of 256 values, so some manipulation must be done. As an example for signed pixel values, if you have a window width (w) of 40 and window centre (c) of 300 then every input (x) value less than or equal to

c - 0.5 - (w-1)/2 = -110

will be given an output (display) value of 0 or black.

Every x value greater than

c - 0.5 + (w-1)/2 = 189

will give an output value of 255 or black.

For everything in between, the appropriate grey level can be calculated by the formula as given below from the DICOM specification to give your output y value in the range between ymin and ymax. As an extra challenge for you, I think you will find that performing this calculation for every pixel everytime the user changes the window settings will make your application run very slowly. A better solution would be to calculate a lookup table to apply pixel display values.

Kevin



Neeraj wrote:
Hello sir

First of all thanks for replying.

I tried to get window width/center as you have suggested.

i need some more light on the issue.

Assuming that i am reading a 16bit CT image,which has both rescale
slope and Intercept within the header,then my x value is what i get
after i apply slope and intercept,

i,e x=eachpixel*slope+intercept {i,e Hounsfield](where eachpixel is
,single value from the array which inturn obtained from the tag
7fe0,0010)

is what i am thinking is right or some thing else?

In eZdicm ,when we first load CT image ,along with the w/l value
it shows one more thing that is Image centre/width,and is initially
calculated as centre =515(for example)

width=3078,

for a window centre /width =40/400(obtained from Tag).

I did a bit of R&d and obtained these values as centre=
(-1024+3078/2)=515,where
-1024 is the lowest value for 16 bit.and 3078 is the highest pixel
value obtained from the array ,which is also is the image width.
I really donot know what is the purpose of doing ths?


so if i have to obtain a ymin and ymax for this CT image is it 0 and
65536(range for 16 bit? or something else ?,

when i am calculating the y value in the final statement weather i
have to use Image width/centre(Obtained from above calculation) or
original WW/Wl(obtained from the tag).

Finally the resultang y ,How can i use this y to adjust W/l?

plaese tell me the use of y.

I know i am asking lot of queries,please do help me ,i am very new to
diom,

A little bit of code to adjust W/l (java or c#) will be a great help.

Thanks to all.















David Clunie wrote:
The value of x is the output of the preceding step, the so-called
"modality LUT", which may either be:

- identity (no rescale values or Modality LUT, or the SOP Class is
PET and rescale values are ignored), in which case x is the stored
pixel value in (7FE0,0010)

- Rescale Slope and Intercept (as typically used in CT), in which
case x is the value obtained from applying the rescale values to
the stored pixel value

- an actual LUT, in which case x is the value stored in the LUT
corresponding to the LUT index value that is the stored pixel
value

The ymin and ymax are intended to represent the output range; for
example, if the hypothetical Presentation LUT step that follows
the VOI LUT (window) stage is an identity operation, then the
ymin and ymax represent P-Values, which might be the range of
digital driving levels for your display (calibrated to the GSDF),
in the 8-bit wide output case ranging from 0 to 255, for example.

The terms brightness and contrast are not used in radiology
imaging - instead the window center and width are used
instead.

David

Neeraj wrote:
Hi kevin.

Thanks for replying.

I know these ,yesterday i was trying to use these staements..

i hav some of questions related to the below lines

1)what is x,is it each pixel in the image array?

2)what is ymin and ymax,is these are the min and max pixel value within
that array?

3)do i have to match resultant y, to some look up table(I donot have
any right now).

or how can i use this y to supply as parameter to brightness or
contrast matrice.

or how to find new w/l value from the y.






Kevin Osborn wrote:

>From the DICOM specification PS 3.3-2004 C11.2.1.2, (p. 698):
where x is the input value, y is an output value with a range from ymin
to ymax, c is window center and w is window width:

if (x <= c - 0.5 - (w-1)/2), then y = ymin

elseif (x > c - 0.5 + (w-1)/2), then y = ymax

else y = ((x - (c - 0.5))/(w - 1) + 0.5) * (ymax - ymin) + ymin

See discussion of VOI LUT module for a more detailed explanation.


Kevin


Neeraj wrote:

Hi Peter,

Thanks for replying .

Now i am able to find Houns field value,and it is working fine,as
you hava mentioned in your previous mail that there is no relation
between W/L and Houns field,now my real problem is how to find W/l, i
tried everywhere but got no answer.

Is there any standard formula exists?,now i have the Cener and width
value(taken from the Tag). how can i make use of these value to
calculate W/l and apply to the contrast and brightness?.

I have two matrices brightness and contrast matrix.which i used for
brightness and contrast upon a trakbar move, instead of trackbar value
is it possible to apply w or l value
to the same matrices.

Please kindly help,i am totally halted here.

Thanks in adwance.

bye
Neeraj.










Peter B Schmidt wrote:

Hello Neeraj,

The Hounsfield Values are not affected by the Center/Window (C/W)
settings, these are affected by "Rescale Intercept" and "Rescale Slope".

C/W tells you, which values have been found eligible to display by the
one who generated the image.

IIRC, you map (Center - 0.5 * window width) to the darkest pixel value
(black), and the brightest value (255 gray = white) to (Center + 0.5 *
window width) - which gives you a span of the width of window width
grayscale values mapped to the range of displayed grays.

I hope this helps to get started, further suggested reading is the DICOM
Standard Display Function explained in Part 14 of the standard.

Kind regards,


Peter

.



Relevant Pages

  • Re: Algorithm for "Windows Center" and "Windows Width"
    ... a typo in my example: window width should be 300 and window center 40. ... For 16 bit pixel values, you have a potential range of 65536 values but you have only a display range of 256 values, so some manipulation must be done. ... Finally the resultang y,How can i use this y to adjust W/l? ... identity (no rescale values or Modality LUT, ...
    (comp.protocols.dicom)
  • Re: Modality LUT from CR
    ... the stored pixel values, and then the output of that becomes the input ... LUT, then the Window Width/Level calculations are applied directly to ... which describes the Grayscale Standard Display Function. ... modality lut is followed by the voi lut ...
    (comp.protocols.dicom)
  • Re: Hello Severian and Mike
    ... display the result to the window (or the ... >> intersections of the viewable area with the rectangles in the result ... >> pixel) is 48MB, so your program will run efficiently only on machines ... For the display, tell us more about how you are doing it. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Algorithm for "Windows Center" and "Windows Width"
    ... I tried to get window width/center as you have suggested. ... -1024 is the lowest value for 16 bit.and 3078 is the highest pixel ... Finally the resultang y,How can i use this y to adjust W/l? ... identity (no rescale values or Modality LUT, ...
    (comp.protocols.dicom)
  • Re: fast window/level
    ... For my window level operation, I've been doing the calculation off the ... // Now map each pixel in the image through the LUT. ... least I will know the bottleneck is truly in the DIB write operations. ... I'm modifying the direct pixel bits of a DIB. ...
    (comp.protocols.dicom)