[vtkusers] Pick a pixel in DICOM series

Manuel Corrales manuelcorrales at gmail.com
Sun Jul 14 11:36:04 EDT 2013


I am trying with this but getting strange values (negative values for z
index for instance):

double* o = image->GetOrigin();
double* s = image->GetSpacing();
indices[0] = static_cast<int>( ( xPos - o[0] ) / s[0] + 0.5 );
indices[1] = static_cast<int>( ( yPos - o[1] ) / s[1] + 0.5 );
indices[2] = static_cast<int>( ( zPos - o[2] ) / s[2] + 0.5 );
return indices;

I am mixing the coordinate somehow? Can you help me?


On Mon, Jun 24, 2013 at 3:41 PM, Manuel Corrales
<manuelcorrales at gmail.com>wrote:

> Thanks Dean! Will try it.
>
>
> On Mon, Jun 24, 2013 at 3:04 PM, Dean Inglis <inglis.dl at gmail.com> wrote:
>
>> Hi Manuel,
>>
>> the example code in
>> Wiki/VTK/Examples/Cxx/Images/PickingAPixel
>> provides the world coordinates of the picked location.  If you want image
>> i,j,k
>>  indices, you have to convert those coordinates yourself using the image
>> data's
>> origin and spacing information.
>> double* o = image->GetOrigin();
>> double* s = image->GetSpacing();
>> int x = static_cast<int>( ( x_world_pos - o[0] ) / s[0] + 0.5 );
>>
>> do similar calcs for y and z.
>>
>> regards,
>> Dean
>>
>>
>>
>>
>> On Thu, Jun 20, 2013 at 6:39 PM, Manuel Corrales <
>> manuelcorrales at gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I am displaying a DICOM series using vtk and "navigating" through the
>>> slices using mouse interaction. I need to pick a pixel from the displayed
>>> image, and I expected to get something like an array of coordinates e.g:
>>> (142, 342, 13) assuming I can use this to actually fetch the data from the
>>> vtkImageData structure.
>>>
>>> I tried to use the PickPixel and PickPixel examples from the wiki, but I
>>> get coordinates with negative numbers
>>>
>>> (Location: ( -49.3894, 37.2297, -97.2094 ))
>>>
>>> and don't know what to do with that. My goal is to be able to pick a
>>> pixel, get a coordinate and being able to use that coordinate to fetch the
>>> pixel color from the vtkImageData.
>>>
>>> Any hints?
>>>
>>> Regards,
>>> Manuel.
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130714/c6d34995/attachment.htm>


More information about the vtkusers mailing list