Picking among many Images in vtkImageStack

Hello everyone,

I have a renderer displaying a vtkImageStack with a bunch of vtkImageSlices (segmentations) with transparent backgrounds. All of the slices should be pickable so I set them all on the same (active) layer, and on the layer below I put the background image (PET scan).

I am having some problems with this implementation:

  1. Even though I set the background image as non pickable and in the bottom layer, which is also not active in the Stack, if I click the background image the picker returns the Stack. Bear in mind this image also has transparent parts which aren’t pickable and that works as expected. Why is this image triggering the pick then?

  2. It appears to be the case that I can not pick among multiple images on the same layer of the Stack because the Pick() function returns the Stack and I can not distinguish which image was picked from here.

Is there something important that I’m missing, or that I misunderstood, or otherwise a solution to my problem?

Thanks in advance!
Best regards, Valentin.

Hi Valentin,

If I’m understanding correctly, the overlay that you want to pick is the one that is not transparent at the cursor position. Unfortunately, that’s not how the ImageStack picking works.

The picking relies on this method, which means that even if multiple images are in the “active layer”, only one of them will ever be picked:

   * Get the active image.  This will be the topmost image whose
   * LayerNumber is the ActiveLayer.  If no image matches, then NULL
   * will be returned.
  vtkImageSlice* GetActiveImage();

Also, the image transparency is only considered with regards to the entire ImageStack, not with regards to the individual images within the stack.

So in order to find the overlay image you want, you must perform the transparency check yourself.

Which picker are you using? The vtkPropPicker, the vtkCellPicker, or maybe some other picker? The different pickers have different behaviors.

1 Like

Thanks for the reply, this calrifies some things.

I am using the vtkPropPicker.
Is the vtkCellPicker a better option here if I want to get the exact Prop to which a Cell belongs? Any hints you could give are greatly appreciated.

Thanks in advance.

That’s not quite how vtkCellPicker works for images. First it finds the image at the pick point, and then it identifies the cell within the image according to where the pick point is.

I see, and what would be a valid approach to picking among many images in a Stack?
Is there otherwise an alternative to the Stack where I can display my images in the right order and still be able to pick them?

As far as I understand, after you get the position from the pick, you have to go through the images in the stack yourself in order to find out which one you want to be “picked”, based on the position.

Also, I think I asked this before, but I don’t think you answered. Do you want to select the “picked” image to be the topmost image that is fully opaque at the pick position? What the criteria by which you would want the picker to select among the images in the stack?

Yes I would like to pick the image with the highest/full opacity at the pick position.

I guess this suggests already a solution to my problem;
Pick-> Get images in the active layer-> return image with highest opacity at pick position

Thank you very much.