# "WL computation" - DICOM

This is a discussion on "WL computation" - DICOM ; Hi all, I have calculated the WL and applied for the CT image which is a 16 bit image. input range =0 to 65536 ,o/p range is 0 to 256. The problem is after applying WL my image is becoming ...

1. ## "WL computation"

Hi all,

I have calculated the WL and applied for the CT image which is a 16
bit image.

input range =0 to 65536 ,o/p range is 0 to 256.

The problem is after applying WL my image is becoming more darker,it
is not showing white pixels.

The code i am using is as below

for (int xi = 0; xi {

x = buff[xi] * Slope + Intercept;

UInt16 y;
if (x <= bottom) y = bymin;
else if (x > top) y = bymax;
else
{
y = (byte)(((x - cmp5) / wm1 + 0.5)
* yrange + ymin);

}
// buff[xi] = (UInt16)(0xff000000 |
(UInt16)(y << 16) | (UInt16)(y << 8) | (UInt16)y);

buff[xi] = y;

}

where buff is my pixels array,

As i increase W and C image is changing but only problem is that it
never shows white pixels.

should be?

Any suggestions will do.
Thanks

2. ## Re: "WL computation"

Your output range should be 0-255 (not 0-256). The value (byte)256 is
the same as (byte)0 so you are setting your white pixels to black.

Kevin

thippeswamy.kn@gmail.com wrote:
> Hi all,
>
> I have calculated the WL and applied for the CT image which is a 16
> bit image.
>
> input range =0 to 65536 ,o/p range is 0 to 256.
>
> The problem is after applying WL my image is becoming more darker,it
> is not showing white pixels.
>
> The code i am using is as below
>
> for (int xi = 0; xi > {
>
> x = buff[xi] * Slope + Intercept;
>
> UInt16 y;
> if (x <= bottom) y = bymin;
> else if (x > top) y = bymax;
> else
> {
> y = (byte)(((x - cmp5) / wm1 + 0.5)
> * yrange + ymin);
>
> }
> // buff[xi] = (UInt16)(0xff000000 |
> (UInt16)(y << 16) | (UInt16)(y << 8) | (UInt16)y);
>
> buff[xi] = y;
>
> }
>
> where buff is my pixels array,
>
> As i increase W and C image is changing but only problem is that it
> never shows white pixels.
>
> should be?
>
>
> Any suggestions will do.
> Thanks
>

3. ## Re: "WL computation"

Yes
Now i have corrected it ,but my problem is for output value 255 the
pixel is not becoming white ,nor for 1000 ,i mean i am not able to get
white pixel for pixel value 255 ,the image is becoming brighter ,but
still pixels which should appear as white are appearing as bright gray
pixels.

How can i make it complete white for 255 itself ,if i increase ymax
to 3000 or 5000 the pixels are becoming white ,but it should,nt be like
that ,so i really dont know what i have missed ,any help for this
problem?

regards
swamy

Kevin Osborn wrote:
> Your output range should be 0-255 (not 0-256). The value (byte)256 is
> the same as (byte)0 so you are setting your white pixels to black.
>
> Kevin
>
>
>
> thippeswamy.kn@gmail.com wrote:
> > Hi all,
> >
> > I have calculated the WL and applied for the CT image which is a 16
> > bit image.
> >
> > input range =0 to 65536 ,o/p range is 0 to 256.
> >
> > The problem is after applying WL my image is becoming more darker,it
> > is not showing white pixels.
> >
> > The code i am using is as below
> >
> > for (int xi = 0; xi > > {
> >
> > x = buff[xi] * Slope + Intercept;
> >
> > UInt16 y;
> > if (x <= bottom) y = bymin;
> > else if (x > top) y = bymax;
> > else
> > {
> > y = (byte)(((x - cmp5) / wm1 + 0.5)
> > * yrange + ymin);
> >
> > }
> > // buff[xi] = (UInt16)(0xff000000 |
> > (UInt16)(y << 16) | (UInt16)(y << 8) | (UInt16)y);
> >
> > buff[xi] = y;
> >
> > }
> >
> > where buff is my pixels array,
> >
> > As i increase W and C image is changing but only problem is that it
> > never shows white pixels.
> >
> > should be?
> >
> >
> > Any suggestions will do.
> > Thanks
> >

4. ## Re: "WL computation"

Yes
Now i have corrected it ,but my problem is for output value 255 the
pixel is not becoming white ,nor for 1000 ,i mean i am not able to get
white pixel for pixel value 255 ,the image is becoming brighter ,but
still pixels which should appear as white are appearing as bright gray
pixels.

How can i make it complete white for 255 itself ,if i increase ymax
to 3000 or 5000 the pixels are becoming white ,but it should,nt be like
that ,so i really dont know what i have missed ,any help for this
problem?

regards
swamy

Kevin Osborn wrote:
> Your output range should be 0-255 (not 0-256). The value (byte)256 is
> the same as (byte)0 so you are setting your white pixels to black.
>
> Kevin
>
>
>
> thippeswamy.kn@gmail.com wrote:
> > Hi all,
> >
> > I have calculated the WL and applied for the CT image which is a 16
> > bit image.
> >
> > input range =0 to 65536 ,o/p range is 0 to 256.
> >
> > The problem is after applying WL my image is becoming more darker,it
> > is not showing white pixels.
> >
> > The code i am using is as below
> >
> > for (int xi = 0; xi > > {
> >
> > x = buff[xi] * Slope + Intercept;
> >
> > UInt16 y;
> > if (x <= bottom) y = bymin;
> > else if (x > top) y = bymax;
> > else
> > {
> > y = (byte)(((x - cmp5) / wm1 + 0.5)
> > * yrange + ymin);
> >
> > }
> > // buff[xi] = (UInt16)(0xff000000 |
> > (UInt16)(y << 16) | (UInt16)(y << 8) | (UInt16)y);
> >
> > buff[xi] = y;
> >
> > }
> >
> > where buff is my pixels array,
> >
> > As i increase W and C image is changing but only problem is that it
> > never shows white pixels.
> >
> > should be?
> >
> >
> > Any suggestions will do.
> > Thanks
> >