[vtkusers] pixel informantion ..

H.Vidal, Jr. hvidal at tesseract-tech.com
Sun Sep 14 01:22:55 EDT 2003


On Sat, 13 Sep 2003, yasser salman wrote:

> hi all..,
> 1- can any body show me how can i  select a pixel using a mouse and
> return me the x, y & intesity of the picked pixel

It would be useful to know your development environment and language of
choice. I have worked vtk under Linux using tcl/tk and C++. Descriptions
below are taken from that context, but should also apply to Windows and
Mac apps.

If you use a vtkTkImageViewerWidget in a tcl/tk app, the right click/drag
(under X/linux box I have tested, in any case..) is bound to a handler
that will return X/Y coordinates and data value in the top left corner
of the client area of the object.

I have found that this data is incorrect in terms of X/Y if you use
a data feed from a vtkImageMagnify, for example. The X/Y coordinates 
appear to be scaled with the image....

> then how can i change
> this pixel color?

Well, changing the pixel color is possible in several contexts:

1. the underlying original data changes
2. some part of a processing pipeline tweaks the data at user-determined
   coordinates; pretty app specific

If you want to change original data, then you worry about a method for the
data in question. For tkImageData, for example, you use
vtkImageData::SetScalarComponentAsFloat(), for example (this is available
under tcl bindings as well). For something like a vtkUnsignedShortArray,
you would translate X/Y/Z coordinates into an offset and pass that to
vtkUnsignedShortArray::SetComponent(). It's application specific.

If you want to change things like the color of a given data value, then
you have to look towards things like color lookup tables. If you have
a given lookuptable that is setup to handle your input data range
correctly, you can either change data values or change values in objects
like vtkLookupTable.

> 2- also is there any example of select a region using a mouse and put
> these selected region on the array?

Trap your mouse coordinates using graphical widgets, then run the selected
ROI through data load methods discussed above.

Hope that helps.

H. Vidal, Jr.
Tesseract Technology




More information about the vtkusers mailing list