How to get coordinates of dicom image and check intensity values over it?

I am using ITK and VTK for liver segmentation purpose. But my ITK segmentation algorithm needs seed point which I have to select from DICOM images. Firstly, I was using 3D slicer to take seed point positions. But Now I have to select it directly from dicom viewer using VTK. And use those position values in my ITK code directly.

I checked PickPixel examples. I have dicom images in .dcm format. So those examples are not showing coordinates for dicom images.

So how can I get a 3D coordinates by just selecting randomly on dicom image? And how to use those position values in my itk code?
Also how to check intensities at different pixel locations ?

Kindly help me with some information.

I’m just curious, why don’t you use 3D Slicer for this? We developed Slicer exactly for making it easy to build medical applications from VTK and ITK. You can completely customize the GUI and disable all the components that you don’t need.

To answer your question, if you only load a single image at a time then you can simply use patient coordinate system (LPS) as your VTK renderer coordinate system. ITK and DICOM uses LPS as physical coordinate system alrwady, so this way all transformations become trivial to compute.

Hello, Thank you for your reply.
Could you please give more details about how to develop Slicer to accomplish segmentation purpose?

Actually I need to create Qt application where I can load my dicom series and do segmentation and visualize the output using ITK & VTK. That’s why I looking for solution in VTK.

If I load Dicom series, then what is the solution to get the (xyz) coordinates by selecting some point on particular slice of series? And also how to check intensity values for all the points by just moving cursor all over image?

Looking forward for some more information. Thanks in advance.

3D Slicer is already a Qt application where you can load your dicom series and do segmentation and visualize the output using ITK & VTK.

See examples in Slicer script repository:

There are many examples of implementing interactive segmentation tools using ITK, in both Python and C++. If you give more details (what programming language you have implemented your custom algorithm, what language you would like to use for specifying custom user interface, what are the inputs for your segmentation tool and what output it creates) then I can give you links to relevant examples.

If you have further Slicer-specific questions then the best is to ask them directly on Slicer forum.

Thank you for given information.
I want to create a QT widget application ( I don’t want to use Slicer for it). I am using C++ as programming language for both segmentation and visualization purpose. (Using ITK and VTK for it).
Also I am taking DICOM data (.dcm files) as input and output also in .dcm format.

I just require the code in c++ to get the volume voxel coordinates and intensities by just clicking on some point of particular slice of Dicom series. And how can I use that coordinates directly in my ITK segmentation code, & then show it in my QT application?
If you have some more information or links related to it, please share it with me.

Thanks again for the help.

I am still searching a solution for seed points int VTK with QT.
I created Qt application, and used SeedwidgetWithCustomCallback example from VTK examples.
It gives me coordinates but those are not helping me in further segmentation procedure.
In Qt, I used QVTKOpenGLWidget to show image, But the image displays at center of that window, which doesn’t give correct coordinates.
Coordinates (X, Y) starts from boundary of widget and not from boundary of dicom image box.
Could you please tell me how to get exact coordinates using VTK or QT, so that I can click anywhere on dicom image (of 512*512) and then use it in my segmentation method?

VTKs picking funcionality will do this. Many pickers would do it for you. I tend to use vtkPointPicker, though I think it’s actually easier with one of the other ones. Here’s how to use it.

vtkPointPicker accepts window coordinates. It’s worth noting that you’ll want to flip the y coordinate from Qt’s mouse events:

picker->Pick(pos.x(), yourVtkRenderer->GetSize()[1] - pos.y(), 0.0, yourVtkRenderer);

Then it will return to you the world coordinate of the point on the actor underneath your mouse. You could place a sphere here to verify it.

Lastly, it’s just a matter of transforming the world coordinate to image coordinate. This could vary depending on how your image is positioned, so you’ll have to figure that one out yourself. But it’s very common to be using an axis aligned image on the XY plane. In which case the x coordinate can be found by: (worldImagePos[0] - imageBounds[0]) / imageSpacing[0]. Which just subtracts the origin and divides by pixel size.

Thank you for this information.
I will try it using vtkPointPicker.

But I tried the same thing already with SeedwidgetWithCustomCallback.
To transform window coordinates to image coordinates, I did (worldImagePos[0] - imageBounds[0]) and then multiply it by scaling factor. I calculated the scaling factor, (windowsize / dicomboundingbox), and that gives me correct coordinates.

But In your given solution. you used imageSpacing[0] i.e. pixel size. What is that? Can you please elaborate this thing more?

Thanks again.

For getting index coordinates… you can directly use the member function transformphysicalpointtocontinousindex in vtkimagedata… This way you can convert ur world coordinates to index coordinates. This worked for my segmentation algorithm.