[vtkusers] Marking a pixel with a filled circle

David Gobbi david.gobbi at gmail.com
Sun Dec 6 12:40:54 EST 2009


On Sun, Dec 6, 2009 at 9:36 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
> I am trying to mark pixels in an image that have been found to be keypoints
> so I can visualize where the keypoints are. If I mark a pixel like this:
>
>   //set the pixel (10,10) to red
>   image->SetScalarComponentFromDouble(10, 10, 0, 0, 255.0);
>   image->SetScalarComponentFromDouble(10, 10, 0, 1, 0.0);
>   image->SetScalarComponentFromDouble(10, 10, 0, 2, 0.0);
>
> the red mark is often too small to even see (since it is only one pixel!).
> Are there any functions to draw a filled circle/square of a specified color
> in an image centered at a specified pixel?

The vtkImageCanvasSource2D has drawing functionality, and you can use
vtkImageBlend to alpha-blend the canvas output into an RGB or RGBA
version of your image.  But I wouldn't recommend it.  There is a
better way to do things!

If you want to annotate an image, don't do it by modifying the image.
Use a vtkActor instead.  For example, use a vtkSphereSource and set
the position of the vtkActor to the pixel location.  In an ideal
world, you could just use actor->SetPosition(image->GetPoint(i,j,k)),
but no such GetPoint() method exists because the interface to
vtkImageData sucks eggs.  Instead, you have to compute the x,y,z
coordinates of the i,j,k pixel yourself.

  David



More information about the vtkusers mailing list