Algorithm for "Windows Center" and "Windows Width" - DICOM

This is a discussion on Algorithm for "Windows Center" and "Windows Width" - DICOM ; Hi I got the Dicom Image From Raw Data Without Applying "WIndows Center" and "Windows Width".Could You Tell me How I can Apply this things For Brightness,Contrast,and for getting Hounsfield Unit.I tried To search Algoritnm for that but i cannot ...

+ Reply to Thread
Results 1 to 10 of 10

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

  1. Algorithm for "Windows Center" and "Windows Width"

    Hi
    I got the Dicom Image From Raw Data Without Applying "WIndows Center"
    and "Windows Width".Could You Tell me How I can Apply this things For
    Brightness,Contrast,and for getting Hounsfield Unit.I tried To search
    Algoritnm for that but i cannot get appropriate solution.
    If any body have solution or idea please share with me.


    regards
    Neeraj Kumar


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

    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

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


    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



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

    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

    >


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

    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

    > >



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

    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
    >>>

    >


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

    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
    > >>>

    > >



  8. 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

    >


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

    Sorry, a typo in my example: window width should be 300 and window
    center 40.

    Kevin




    Kevin Osborn wrote:
    > 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

    >>


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

    Hi

    Thanks for the reply.


    I followed your method ,still i did'nt get any thing.

    Below is the piece of code.

    Image -16 bIt CT image.

    destBuffer is my image pixel array.

    Slope and Intercept are taken from Tag 0028,1053 and 0028,1052
    respectively.

    double val = c - 0.5 - (w - 1) / 2;//c is centre=40
    double val1 = c - 0.5 + (w - 1) / 2;//w is width=400
    //val=-160,val1=239

    for (int i = 0; i < dstBuffer.Length; i++)
    {
    pix[i] = (dstBuffer[i] * slope +Intercept);//Hounfield
    since CT image

    if (dstBuffer[i] <= val)
    {
    dstBuffer[i] = 0;
    }


    else if (dstBuffer[i] > val1)
    {
    dstBuffer[i] = 255;
    }


    else
    {
    Y = (float)((pix[i] - (c-0.5)) / (w-1) + 0.5) *
    (255 - 0) + 0;
    dstBuffer[i] = (byte)Y;
    }



    }


    //Creating image for the DestBuffer


    Bitmap bitmap = new Bitmap(DicomFile.PixelData.Columns,
    DicomFile.PixelData.Rows,
    DicomFile.PixelData.Columns * 8,
    System.Drawing.Imaging.PixelFormat.Format64bppArgb , pObject);


    am i using the output Y correctlu?
    am i doing anything wrong?


    I am getting blank screen ,i just want to test by changing w and c
    values,
    so please help me

    Thanks all




    Kevin Osborn wrote:
    > Sorry, a typo in my example: window width should be 300 and window
    > center 40.
    >
    > Kevin
    >
    >
    >
    >
    > Kevin Osborn wrote:
    > > 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
    > >>



+ Reply to Thread