[vtkusers] DICOM pixel value is strange

Cory Quammen cory.quammen at kitware.com
Fri Oct 20 08:57:49 EDT 2017


It looks like you are casting the array pointer to a double array. Are your
values actually stored in doubles? Your expected range of [0, 255] suggests
they would actually be stored as unsigned chars, so first try to change your

static_cast<double*>(image->GetScalarPointer(ijk));

to

static_cast<unsigned char*>(image->GetScalarPointer(ijk));

Hope that helps,
Cory

On Fri, Oct 20, 2017 at 3:06 AM, arwtyxouymz <arw.tyx-ouy_mz at ezweb.ne.jp>
wrote:

> Hi,
>
> I wrote the code to pick the DICOM pixel value, but pixel value is strange.
> My code is below:
>
> ```
> vtkSmartPointer<vtkImageData> image = reader->GetOutput();
>
> int ijk[3];
> double pcoords[3];
>
> for (vtkIdType id = 0; id < image->GetNumberOfPoints(); ++id) {
>         int check = image->ComputeStructuredCoordinates(
> image->GetPoint(id),
> ijk, pcoords);
>         cout << "ID: " << id << ", ";
>         cout << "ijk: " << "(" << ijk[0] << ", " << ijk[1] << ", " <<
> ijk[2]
> << "), ";
>         auto *pixel = static_cast<double*>(image->GetScalarPointer(ijk));
>         cout << "Pixel: " << *pixel << endl;
> }
> ```
>
> I supposed *pixel value is in the range 0 ~ 255, but actual output is like
> -2.06898e+289.
> Why?
> Moreover, *pixel max value is 1.98914e-289, and sometimes *pixel is nan.
> It's strange!!!
>
> Can you help me?
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>



-- 
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171020/43383820/attachment.html>


More information about the vtkusers mailing list