[vtkusers] Marking a pixel with a filled circle

David Doria daviddoria+vtk at gmail.com
Sun Dec 6 19:25:22 EST 2009


On Sun, Dec 6, 2009 at 12:40 PM, David Gobbi <david.gobbi at gmail.com> wrote:

> On Sun, Dec 6, 2009 at 9:36 AM, David Doria <daviddoria+vtk at gmail.com<daviddoria%2Bvtk 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
>

vtkImageCanvasSource2D was exactly what I was looking/asking for, thanks!
Although I agree that it is not a good plan to actually modify the pixels
just to visualize something, this may be useful to write out images to
remind myself of the results obtained at a later date.

I made an example:
http://www.vtk.org/Wiki/VTK_Examples_Drawing
it attempts to read an input image and then draw on top of it. Since
vtkImageCanvasSource2D is a source, this does not seem to be how it is
supposed to operate. Instead I copied the Extent of the input image and draw
on a blank image. I have two questions:
1) I set the draw color to what I believe is red ( (r, g, b, a) I was
guessing). The resulting circle was white. Anyone know why?

2) How would I copy this image "onto" the input image so it was as if I drew
on the input image?

David - What you mentioned about the ImageData interface is interesting...
it would definitely be nice to have good methods for determining:
a) world space coordinates of an image actor pixel
b) world space coordinates of an image actor pixel
c) image space coordinates of a screen space point (ie. which pixel in the
image does a clicked point in the window (on the image actor) correspond
to?)


Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091206/5f0a06e0/attachment.htm>


More information about the vtkusers mailing list