<div dir="ltr"><div><div>Here's the answer to my stupid question..<br><br></div>Rescale Intercept is -1024 in my DICOM image, and RescaleSlope is 1. Then following this rule:<br>Pixel(x,y) = Data(x, y) * Rescale Slope + Rescale Intercept<br>
</div>I get the 62512<br><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jan 25, 2014 at 12:00 AM, Matias Montroull <span dir="ltr"><<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Why the vtkUnsignedShortArray returns a different ushort value than the one in the image?<div><br></div>
<div>See the beginning of my image is: (2 bytes each pixel)</div><div><br></div><div><div><b>48 248</b> 48 248 48 248 48 248 48 248 48 248 48 248 48 248</div>
<div>48 248 48 248 48 248 48 248 48 248 48 248 48 248 48 248</div><div>48 248 48 248 48 248 48 248 48 248 48 248 48 248 48 248</div><div>48 248 48 248 48 248 48 248 48 248 48 248 48 248 48 248</div><div>48 248 48 248 48 248 48 248 48 248 48 248 48 248 48 248</div>

<div>48 248 48 248 48 248</div></div><div><br></div><div>and vtk returns 62512 on every ushort when it should return 63536!</div><div><br></div><div>Can you explain why is this or am I missing something?</div></div><div class="HOEnZb">
<div class="h5"><div class="gmail_extra">
<br><br><div class="gmail_quote">On Fri, Jan 24, 2014 at 10:58 PM, Matias Montroull <span dir="ltr"><<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">One more thing, I noticed the data type is "short", so how I get the values in that case?<br></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 24, 2014 at 10:25 PM, Matias Montroull <span dir="ltr"><<a href="mailto:matimontg@gmail.com" target="_blank">matimontg@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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><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><font color="#888888"><br>
  David<br>
</font></span><div><div><br>
<br>
<br>
On Fri, Jan 24, 2014 at 3:46 PM, Matias Montroull <<a href="mailto:matimontg@gmail.com" target="_blank">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>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>