Get Pixel data

127 views
Skip to first unread message

Matias

unread,
Aug 10, 2013, 9:00:21 PM8/10/13
to fo-d...@googlegroups.com
Hi,

How can I get the pixel data from a Dicom Image?

Right now I do this:

 List<ushort> pixels16;
then
pixels16 = new List<ushort>();

and then...

 pixels16 = img[0].PixelData.GetFrame(0).Data.ToList();

and I'm gettign this error:
Cannot implicitly convert type 'System.Collections.Generic.List<byte>' to 'System.Collections.Generic.List<ushort>'


Matias

unread,
Aug 11, 2013, 8:22:42 PM8/11/13
to fo-d...@googlegroups.com
I got the Pixel Data of a 16 bits image.. Here's the code:

List<ushort> pixels16;

....
  byte[] bytes = img.PixelData.GetFrame(0).Data;
                int count = bytes.Length / 2;
                ushort[] words = new ushort[count];
                for (int i = 0, p = 0; i < count; i++, p += 2)
                {
                    words[i] = BitConverter.ToUInt16(bytes, p);
                }
                pixels16 = words.ToList();

Reply all
Reply to author
Forward
0 new messages