[vtkusers] picking vtkImageSlice using vtkCellPicker?
David Gobbi
david.gobbi at gmail.com
Tue Mar 25 15:49:58 EDT 2014
Hi Miro,
As far as I know, no VTK components whatsoever are tested for images
with negative spacing, and no-one is working to fix the components
that are known to break with negative spacing.
In my own software, whenever I read an image that has negative
spacing, I always reverse the slice order to make the spacing
positive. This means that I have to modify the orientation/position
matrix to account for the reversal, and it also means that I have to
create a map that will map imagedata slice indices to the original
file slice indices. All of this adds complexity to my programs,
obviously, but at least it means that I can be confident that all the
rendering, contouring, filtering, and picking tools will properly work
with my data.
Since I'm familiar with the image picking code, I can take a look to
see why it doesn't work for negative spacing. But I strongly
recommend that you do not use images with negative spacing in VTK.
If you use negative spacing, then some things will work, it's true, but
some things will break.
David
On Tue, Mar 25, 2014 at 1:24 PM, Miro Drahos <mdrahos at robodoc.com> wrote:
> Hi David,
> I investigated this issue further and indeed vtkCellPicker works fine with
> vtkImageActor/vtkImageSlice when I plug in different images.
> It so happens that my image has negative spacing (in z-direction), and that
> seems to cause issues. If I load the same image and flip the z-spacing sign,
> picking works fine. I had a look at the vtkImageActor class and saw the
> if-clauses taking care of the spacing sign (when setting display bounds),
> but I have not seen a similar treatment in vtkImageSliceMapper -- is it
> possible that the issue is there?
> I have had issues with images with negative spacing before, in particular
> marching cubes filter as well as volumeMapper don't support the negative
> spacing (in vtk 5.10). I was able to work around this by flipping the
> spacing (and changing the origin) but I would rather keep the negative
> spacing as is, since that's how the slices were acquired, in the -z
> direction.
> Do you (or anyone else?) know where in the vtk codebase could this problem
> (picking dependent on the spacing sign of the image) be?
> I believe that picking takes into consideration just the actor bounds, but
> the rendering works just fine, so I am quite puzzled.
> I am hoping that once I know where the problem is, I can derive a class
> implementing the correct behavior and use that instead.
> Any advice is greatly appreciated, as always.
> Best,
> Miro
>
>
>
>
> On 03/20/2014 02:29 PM, David Gobbi wrote:
>>
>> Hi Miro,
>>
>> I checked through the git logs, the only recent fix to vtkCellPicker
>> had to do with the fact that GetMapper() returned null for
>> vtkImageSlice (but it still returned the prop and position just fine).
>> However, I noticed that the only nightly test for picking images uses
>> a vtkImageActor (a subclass of vtkImageSlice) instead of using
>> vtkImageSlice directly. This shouldn't make a difference, but it
>> might be worth investigating.
>>
>> David
>>
>> On Thu, Mar 20, 2014 at 2:17 PM, Miro Drahos <mdrahos at robodoc.com> wrote:
>>>
>>> Hi David,
>>> thank you for your prompt response.
>>>
>>> I am using VTK 5.10 and doing nothing special as far as I can tell. Here
>>> is
>>> some more details:
>>>
>>> I have a vector of vtkSmartPointer<vtkImageSlice> objects to display
>>> images
>>> [my 3D CT image has several segments with different slice thicknesses, so
>>> that's why I have a vector of them]. All the reslicing and visualization
>>> is
>>> working as expected, so I don't suspect an issue there.
>>> Now I am observing LeftMouseEvent of the interactor and processing it in
>>> my
>>> callback class to recognize when the surface model is picked. If it is,
>>> then
>>> user can translate and rotate it. The callback class is derived from both
>>> vtkCommand and QObject (to be able to use signal/slots of Qt that this is
>>> part of) and I am implementing FindPickedActor(int x, int y) method as I
>>> have seen it throughout VTK many times.
>>> I have tried to use different pickers, and decided for vtkCellPicker
>>> instead
>>> of vtkPropPicker, to be able to set tolerance (user can make the surface
>>> model transparent and then might want to pick just the outline --
>>> intersection of the surface and the image reslice plane. Picking outline
>>> is
>>> hard with no tolerance).
>>> Picking surface model works just fine.
>>>
>>> Here is the Print() of one of my vtkImageSlice instance:
>>>
>>> vtkImageSlice (0x4ecbd30)
>>> Debug: Off
>>> Modified Time: 64690
>>> Reference Count: 3
>>> Registered Events: (none)
>>> Dragable: On
>>> Pickable: On
>>> AllocatedRenderTime: 860.822
>>> EstimatedRenderTime: 0
>>> NumberOfConsumers: 1
>>> RenderTimeMultiplier: 0.863803
>>> Visibility: On
>>> PropertyKeys: none.
>>> useBounds: 1
>>> IsIdentity: true
>>> Position: (0, 0, 0)
>>> Orientation: (0, 0, 0)
>>> Origin: (0, 0, 0)
>>> Scale: (1, 1, 1)
>>> Bounds:
>>> Xmin,Xmax: (-100, 100)
>>> Ymin,Ymax: (-100, 100)
>>> Zmin,Zmax: (-90.625, -2.5)
>>> UserTransform: (none)
>>> UserMatrix: (none)
>>> Property:
>>> Debug: Off
>>> Modified Time: 64690
>>> Reference Count: 3
>>> Registered Events: (none)
>>> ColorWindow: 260.1
>>> ColorLevel: 119.85
>>> UseLookupTableScalarRange: Off
>>> LookupTable: 0x156088a0
>>> Opacity: 1
>>> Ambient: 0.3
>>> Diffuse: 1
>>> InterpolationType: Linear
>>> LayerNumber: 0
>>> Checkerboard: Off
>>> CheckerboardSpacing: 10 10
>>> CheckerboardOffset: 0 0
>>> Backing: Off
>>> BackingColor: 0 0 0
>>> Mapper:
>>> Debug: Off
>>> Modified Time: 96181
>>> Reference Count: 3
>>> Registered Events: (none)
>>> Executive: 0x4ecc950
>>> ErrorCode: Success
>>> Information: 0x4ecc440
>>> AbortExecute: Off
>>> Progress: 1
>>> Progress Text: (None)
>>> TimeToDraw: 0
>>> ClippingPlanes: (none)
>>> SlicePlane: 0x4691280
>>> SliceAtFocalPoint: Off
>>> SliceFacesCamera: Off
>>> Border: On
>>> Background: Off
>>> NumberOfThreads: 8
>>> JumpToNearestSlice: Off
>>> AutoAdjustImageQuality: On
>>> SeparateWindowLevelOperation: On
>>> ResampleToScreenPixels: On
>>> SlabThickness: 0
>>> SlabType: Mean
>>> SlabSampleFactor: 2
>>> ImageSampleFactor: 1
>>> Interpolator: 0x4ecf330
>>> Bounds: (-100, 100) (-100) (100) (-90.625) (-2.5)
>>>
>>> I will make a simple mock program and try to isolate the problem.
>>> Thank you once again!
>>> Miro
>>>
>>>
>>>
>>>
>>> On 03/20/2014 12:31 PM, David Gobbi wrote:
>>>>
>>>> Hi Miro,
>>>>
>>>> You'll have to provide more details, because I use vtkCellPicker on
>>>> vtkImageSlice all the time. It's even part of the nightly VTK testing.
>>>> Is there anything special about the way you use the vtkImageSlice?
>>>> What version of VTK are you using?
>>>>
>>>> David
>>>>
>>>> On Thu, Mar 20, 2014 at 1:15 PM, Miro Drahos <mdrahos at robodoc.com>
>>>> wrote:
>>>>>
>>>>> Hi all,
>>>>> I am rendering an image slice using vtkImageSlice and a surface
>>>>> (vtkActor).
>>>>> When I perform picking using vtkCellPicker, I always pick the surface
>>>>> actor,
>>>>> even if it is in the background, behind the vtkImageSlice.
>>>>> If I try to pick the vtkImageSlice (and the ray does not intersect the
>>>>> surface actor), the Pick() method returns 0, as well as
>>>>> picker->GetPath()
>>>>> returns NULL. The vtkImageSlice is set to be pickable.
>>>>> I am quite baffled by this, since I'd expect to be able to pick
>>>>> vtkImageSlice with vtkCellPicker, since it is a vtkProp3D.
>>>>> If I use vtkPropPicker, I can pick the image slice fine, but I would
>>>>> prefer
>>>>> to use vtkCellPicker so that I can specify picking tolerance.
>>>>> Can someone shed some light on this?
>>>>> Thank you tons!
>>>>> Miro
>>>
>>>
>
> _______________________________________________
> 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
More information about the vtkusers
mailing list