I want to implement in my application the possibility to have an xy plot of the intensity values of an image along the X or the Y axis. I have tried to draw vtkLineSource on top of my image and extract the intensity values with vtkImageProbeFilter but this approach doesn’t work. Do you have Any suggestion on how to implement this?
It should definitely be possible to do this with either vtkImageProbeFilter or with vtkProbeFilter. Here’s a short checklist:
Make sure the line has enough points, e.g. SetResolution(100)
Make sure the Bounds of the line are within the Bounds of the image
For the latter, note that both vtkPolyData (the line) and vtkImageData (the image) have a GetBounds() method, so the bounds check should be easy to do.
Are you working with 3D images or 2D images? For 2D, the line points must lie within the plane of the image.
Once the intensity values are attached to the line, it should be possible to use vtkWarpScalar to turn the line into a profile that can be rendered on the image.
Yes, one point per image voxel will make a good profile. You can use SetResolution(size-1) to get the correct number of points. The resolution is the number of segments, which is one less than the number of points.
Is the z coordinate of your image always 1, and not 0? To me, it seems strange that your coordinates start at 1 instead of 0, so I expected something like this:
As a next step, you can try putting the output of probe2 into vtkWarpScalar, and then render the output of vtkWarpScalar. If everything works, it will look like a profile.
I still suspect that your line is not placed correctly, and is therefore not within the image bounds. Have you checked the numerical values of the scalars that are produced by the probe filter?
Here is a small Python example that I wrote for image probing: