<div dir="ltr"><div><div>Thanks David,<br><br></div>So, I've done this and works perfect:<br><br> vtkDICOMImageReader reader = vtkDICOMImageReader.New();<br> reader.SetFileName(@"C:\DICOM\img1.dcm");<br>
reader.Update();<br> vtkImageData vtkimagedata_imagen = reader.GetOutput();<br> vtkDataArray array_bytes = vtkimagedata_imagen.GetPointData().GetScalars();<br> vtkUnsignedShortArray ushortArray_imagen = vtkUnsignedShortArray.New();<br>
ushortArray_imagen.DeepCopy(array_bytes);<br> int[] abc = new int[array_bytes.GetDataSize()];<br> for (int i = 0; i < array_bytes.GetDataSize(); i++)<br> {<br>
abc[i] = ushortArray_imagen.GetValue(i);<br> }<br> <br></div>One more question, is it possible to re-create a Dicom Image from an ushort Array?<br><br>Thanks again,<br><br>Matias.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 24, 2014 at 8:24 PM, David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com" target="_blank">david.gobbi@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Matias,<br>
<br>
If you have a vtkImageData object, you can get the array though<br>
VTK's abstract data set interface. Here's an example:<br>
<br>
vtkImageData *image = reader->GetOutput();<br>
vtkDataArray *array = image->GetPointData()->GetScalars();<br>
<br>
This will return an array that contains the scalars that are<br>
associated with each point in the data. For vtkImageData, this<br>
means the length of the array is the number of pixels in the image,<br>
so the length will be 262144 (which is 512*512).<br>
<br>
If the data is DICOM, the array will probably already be either a<br>
vtkUnsignedShortArray or a vtkShortArray (signed short). But to<br>
be sure, you can do a conversion:<br>
<br>
vtkUnsignedShortArray *ushortArray = vtkUnsignedShortArray::New();<br>
ushortArray->DeepCopy(array);<br>
<br>
With the ushort array, you can use GetValue(i) to get one of the values.<br>
<span class="HOEnZb"><font color="#888888"><br>
David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Fri, Jan 24, 2014 at 3:46 PM, Matias Montroull <<a href="mailto:matimontg@gmail.com">matimontg@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> is there a way to obtain the byte array from a Dicom Image?<br>
><br>
> I can display the image but I also need to extract the byte data, it's a<br>
> 512X512 16 bits image, so I need the Ushort array.<br>
><br>
> Thanks!<br>
</div></div></blockquote></div><br></div>