[Insight-users] Re: [vtkusers] pixel data at world position

Renaud Isabelle renauisa at yahoo.fr
Wed Oct 5 16:35:15 EDT 2005


Hi again, 
 
Ok, I checked out the difference between picker->GetPickPosition() and picker->GetMapperPosition(), and in my case, they are always the same: goo for me! 
 
So, I still have my selection point (X,Y) in pixel coordinates, and my real position in world (x,y,z), but i would like to know how to retrieve the pixel value of my itkImage since I have got my real position in world. 
 
BTW, did you finally manage to set a pixel that your user clicks on to a certain color, as you mentioned in your posted mail http://public.kitware.com/pipermail/vtkusers/2005-May/079622.html? 
This could be exactly what I would like to do.
 
Isabelle

Mark Wyszomierski <markww at gmail.com> a écrit :
Hi Isabelle,
 
So my observer is a class, who has a member to my 'view' class, as well as some storage for
the mapped point. Pseudo code looks like:

class vtkObserverLeftMouseDown : public vtkCommand {
    public:
        CMyView *m_pView;
        double ptMapped[3];
};
Now to fill in some of the blanks, the actual function looks like:
 
void vtkObserverLeftMouseDown ::Execute(vtkObject *caller, unsigned long, void*) 
{
    m_pView->Picker->Pick(m_pView->Interactor->GetEventPosition()[0], 
                                        m_pView->Interactor->GetEventPosition()[1], 
                                        0, 
                                        m_pView->Renderer);
    m_pView->Picker->GetMapperPosition(ptMapped);
}
 
Once ptMapped is filled in for you, you can do the equation where you divide by the
pixel spacing etc. The (int)(+ 0.5) is just a shortcut for rounding - it is to make the
final determination about what pixel you're over. It is not related to my origin. You'll
have to come up with a way to get your picker to the observer. Using a pointer to
my view class worked for me. 
 
Mark
 
 
 
On 10/5/05, Renaud Isabelle <renauisa at yahoo.fr> wrote: Hi Mark,
 
Thanks for replying. 
 
I have already computed my world position by firing a picker from pixel coordinates. Sorry but I don't see or know what the mapper coordinates are. What is the difference and how this could help me to retrieve the index in my itkImage's buffer corresponding to my world position?   
 
BTW, what is your '+ 0.5'? I suppose this is the origin in x of your image, right? 
 
Isabelle

Mark Wyszomierski <markww at gmail.com> a écrit :
You can fire a pick event when the user clicks the mouse:
 
    Picker->Pick(eventpos[0], eventpos[1], 0, renderer);
    
Then you can get the mapped position:
 
    Picker->GetMapperPosition(...);
 
Then  the final x,y locs of the original image I get by:
 
    originalX = (int)(ptMapped[0] / pixel_spacing_x + 0.5);
    // same for y.
 
This always has given me the correct 'real' location.
 
Mark

 
On 10/5/05, Renaud Isabelle <renauisa at yahoo.fr > wrote: Hi all,
 
I have read an initial 3D image from a file with itkImageFileReader and displayed with VTK through vtkImageData/vtkImageActor.
 
Now, since a known world position in 3D x,y,z, I would like to retrieve the pixel value at this point of my image. 
 
This seems to be a complex problem, because I don't want the pixel data that is displayed at this position but the pixel data of the raw image, that is no rescaled instead.
 
Is there some example where such a thing is done? Or any function? 
 
Thanks, 
 
Isabelle
 
   
 
 


---------------------------------
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez le ici ! 








_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers 






---------------------------------
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez le ici ! 







		
---------------------------------
 Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
 Téléchargez le ici !  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20051005/6ebe3d82/attachment-0001.htm


More information about the Insight-users mailing list