[vtkusers] vtkImageSlice question

Siddharth Vikal siddharthvikal at gmail.com
Fri May 4 09:55:42 EDT 2012


Thanks for the recipe David, it works like a charm!

On Fri, May 4, 2012 at 2:09 AM, David Gobbi <david.gobbi at gmail.com> wrote:

> The recipe for getting image pixels to match screen pixels is, roughly:
>
> render_window->Render();
> int *rsize = renderer->GetSize();
> int height = rsize[1];
> vtkCamera *camera = renderer->GetActiveCamera();
> camera->ParallelProjectionOn();
> camera->SetParallelScale(0.5*height*yspacing);
> render_window->Render();
>
> If the image is not yet calibrated, then it should be fine to use
> a yspacing of 1.
>
>  - David
>
>
> On Thu, May 3, 2012 at 11:33 AM, Siddharth Vikal
> <siddharthvikal at gmail.com> wrote:
> > Thanks David for detailed response.
> >
> > Thanks, yes I do understand now more clearly the series of
> transformations
> > that the image goes through when vtkImageSlice or vtkImageActor is in
> use.
> > And I completely agree and am for, equating the world coordinate system
> with
> > the DICOM patient coordinate system. It is the camera transformations and
> > view transformation I'm interested in (world --> view --> screen).
> >
> > Perhaps, it would make more sense to you if I explain the particular
> > scenario a bit better. Consider the situation where the image that one
> has
> > acquired are just off the hardware, where the spacing of voxels is not
> yet
> > known. A manual calibration step is then needed to actually determine the
> > pixel spacing. In this case, user prefers to the see the image as and
> how it
> > comes out of the hardware i.e. the native pixel size equated to computer
> > monitor's pixels. Based on that calibrated pixel size, the measurements
> have
> > to added to image.  My thought was that since vtkDistanceWidget works
> well
> > with vtkImageActor/vtkImageSlice, it would help to know the exact
> scaling so
> > that I can accurately calculate calibrated pixel size and enable
> > vtkDistanceWidget display correct measurements.
> >
> > regards,
> > Siddharth
> >
> >
> > On Thu, May 3, 2012 at 8:38 PM, David Gobbi <david.gobbi at gmail.com>
> wrote:
> >>
> >> Hi Siddharth,
> >>
> >> If you just want to map your image pixels directly to screen pixels,
> >> then there's hardly any reason to use a computer graphics toolkit like
> >> VTK at all.  The goal of vtkImageActor and vtkImageSlice is to place
> >> an image into a 3D scene, so that the vtkCamera can then be set up to
> >> view that scene from a particular viewpoint.
> >>
> >> There are several coordinate transformations that occur along the way.
> >>
> >> First, the sampling information for the image is applied, i.e. the
> >> spacing and voxels and the position of the lower-left corner voxel of
> >> the image volume (or upper-left in the case of DICOM).  This
> >> transformation maps the voxels to a physical block of space (usually
> >> using millimetres as units).
> >>
> >> Next, the prop3D transformation is applied.  This establishes the
> >> position of the aforementioned block of space within the world
> >> coordinate system. For medical applications, I always equate the world
> >> coordinate system with the DICOM patient coordinate system of my
> >> primary image series, in order to keep things simple.
> >>
> >> Next, there are two camera transformation that are applied (a view
> >> transformation and a projection transformation) that map the world
> >> coordinates to the view coordinates, followed by a viewport
> >> transformation that maps the viewport coordinates to screen pixels.
> >>
> >> None of these transformations are specific to VTK.  The same basic
> >> approach is used in virtually all modern computer graphics libraries.
> >>
> >> There are recipes that you can apply to achieve basic effects (e.g
> >> like viewing a 2D slice of an image at a specific zoom factor), but in
> >> order to get the most out of VTK, it is important understand the
> >> computer graphics fundamentals that underlie the toolkit.
> >>
> >>  - David
> >>
> >>
> >> On Thu, May 3, 2012 at 7:32 AM, sidd_vtk <siddharthvikal at gmail.com>
> wrote:
> >> > Hi David & all vtk users,
> >> >
> >> > I'm using the newly added vtkImageSlice class (I've used vtkImageActor
> >> > also
> >> > with the same issue that I'm describing below). I set up the pipeline,
> >> > and
> >> > the image shows up. The issue is that the image that comes up does not
> >> > preserve its original size in pixels unlike how vtkActor2D does. To be
> >> > more
> >> > specific and clear, e.g. if the image size in pixels is 512x512, the
> use
> >> > of
> >> > vtkActor2D results in displaying the image of size 512x512 pixels, but
> >> > use
> >> > of vtkImageSlice or vtkImageActor displays in size other than true
> size
> >> > of
> >> > the image. And I can't seem to figure out the scale factor that has
> been
> >> > applied.
> >> >
> >> > I need to use vtkImageSlice or vtkImageActor, because they work well
> >> > with
> >> > vtkDistanceWidget. But I also require 1:1 display of the image. If the
> >> > scale
> >> > factor is known, I can re-transform my image to get what I want.
> >> >
> >> > Can you please point me the code where this re-scaling of the image
> >> > happens
> >> > before it gets rendered? or How to fetch the scaling that has been
> >> > applied
> >> > to the image when vtkImageSlice or vtkImageActor has been used?
> >> >
> >> > Any help is greatly appreciated.
> >> >
> >> > regards,
> >> > Siddharth
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120504/fcbd4c23/attachment.htm>


More information about the vtkusers mailing list