[vtkusers] Where's my Reslice?
Eric E. Monson
emonson at cs.duke.edu
Wed Apr 28 13:58:41 EDT 2010
Hey Scott,
Well, you're starting to get out of my experience range here with combining volume rendering and other geometry, plus I'm not a core developer, so hopefully someone higher up will think about your ideas of creating more similar APIs for these classes.
As a test I was able to take what I think might be a MIP volume rendering example (vtk/Examples/VolumeRendering/Python/SimpleRayCast.py) and add a plane using basically the pipeline you mentioned. After the reader I added:
reader.Update()
(xmin,xmax,ymin,ymax,zmin,zmax) = reader.GetOutput().GetBounds()
plane = vtk.vtkPlaneSource()
plane.SetOrigin((xmin-5, ymin-5, zmax/2))
plane.SetPoint1((xmax+5, ymin-5, zmax/2))
plane.SetPoint2((xmin-5, ymax+5, zmax/2))
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(plane.GetOutputPort(0))
actor = vtk.vtkActor()
actor.SetMapper(mapper)
and then later on just added:
ren.AddActor(actor)
and it seemed to work. I'll attach a small screen shot. If this isn't what you're trying to do, then someone else might have to chime in with ideas.
Good luck,
-Eric
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MIPwithPlaneTry.png
Type: image/png
Size: 14385 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100428/06923094/attachment.png>
-------------- next part --------------
On Apr 27, 2010, at 4:09 PM, Scott Johnson wrote:
> Thanks Eric,
>
> Is there a simple way to display the plane orientation in a MIP
> rendering?
>
> I tried to create a vtkPlaneSource which reflected the reslice
> orientation then connecting to a vtkActor and into the renderer. The
> pipeline was vtkPlaneSource->vtkPolyDataMapper->vtkActor->vtkRenderer.
> The result was either no plane showing up, or a single line sticking
> into the volume.
>
> As an aside: It would be really handing if all of the *Plane* classes
> had a common mechanism for specifying the orientation and location of
> the plane. Maybe connect a vtkTransform to all of them. Right now,
> vtkPlane and vtkPlaneSource allow you to set the Normal and the Center,
> but vtkImageReslice does not. vtkPlaneSource also allows you to set the
> orientation as 2 points, vtkImageReslice does not. vtkImageReslice
> allows you to specify the vtkTransform or DirectionCosines, but the
> others do not.
>
> Connecting the vtkTransform would be nice because if you had to
> coordinate a number of these things you could set the orientation in one
> place and have it propagated to the others. In my case, I'm using a
> vtkPlane to attach to a vtkCutter for geometry, vtkImageReslice for
> cutting images, and I'd like to connect a vtkPlaneSource to display the
> plane location within a MIP rendered volume. They all need to have the
> same position and orientation.
>
> Thanks
>
> -- Scott
>
> -----Original Message-----
> From: Eric E. Monson [mailto:emonson at cs.duke.edu]
> Sent: Tuesday, April 27, 2010 2:56 PM
> To: Scott Johnson
> Cc: Jothy; vtkusers at vtk.org
> Subject: Re: [vtkusers] Where's my Reslice?
>
> Hey Scott,
>
> I think your initial combination of 3-dimensional output from
> vtkImageReslice and vtkImageViewer2 should be fine. It is probably just
> a matter of correctly specifying the axis for your reslice filter. You
> can probably take a look at those examples for setting the reslice axis
> with the matrix (including specifying the center position of the axis,
> which may have been causing your problem), and then use vtkImageViewer2
> just as you were intending.
>
> Good luck,
> -Eric
>
>
> On Apr 27, 2010, at 3:42 PM, Scott Johnson wrote:
>
>> Thanks Eric,
>>
>> I'm sorry I forgot to say the settings for vtkImageChangeInformation.
> I
>> just invoked CenterImageOn to have the images display. I was working
>> under the assumption that I was specifying the cut location of the
>> vtkImageReslice correctly, but wasn't displaying it correctly.
>>
>> I did look at ImageSlicing.cxx. It manages the vtkImageActor on its
>> own, without using vtkImageViewer2. That's what prompted my initial
>> question of: Is vtkImageViewer2 maybe setting something that is
>> throwing me off? I think I'm going to have to go that route.
>>
>> If I specify SetDimensionality(3) for the vtkImageReslice, I thought I
>> would be getting a stack of slices. My plan was then to use
> SetSlice(n)
>> to allow the user to move through the slices. Is that the wrong
>> assumption?
>>
>> -- Scott
>>
>> -----Original Message-----
>> From: Eric E. Monson [mailto:emonson at cs.duke.edu]
>> Sent: Tuesday, April 27, 2010 2:31 PM
>> To: Scott Johnson
>> Cc: Jothy; vtkusers at vtk.org
>> Subject: Re: [vtkusers] Where's my Reslice?
>>
>> Hey Scott,
>>
>> I'm not an expert on this, (and you didn't describe what you had to
> put
>> in your vtkImageChangeInformation to see the other views), but it
> sounds
>> a bit like maybe there's just something wrong with how you're
> specifying
>> your transform to get your slice, so you're not really slicing through
>> where you think you are. The output of the reslice filter should just
> be
>> an image (i.e. a vtkImageData which is only 1-deep, so it's flat like
> an
>> image instead of what you'd think of as a volume).
>>
>> Have you taken a look at this example?
>> [vtk_source]/Examples/ImageProcessing/Cxx/ImageSlicing.cxx (or its
>> Python or Tcl equivalent)
>>
>> That one shows very nicely how to specify a 4x4 matrix which controls
>> the slice axis (set with reslice->SetReliceAxes(resliceAxes) ), and
> uses
>> a vtkImageActor and standard vtkRenderWindow to display the image. If
>> you haven't, maybe you can at least play with those methods and see if
>> they make any difference.
>>
>> -Eric
>>
>>
>> On Apr 27, 2010, at 3:08 PM, Scott Johnson wrote:
>>
>>> It was my understanding that those allow the plane orientation to be
>> manipulated and display the plane in space. I want the 2D result of
> the
>> reslice to be presented to the user as a 2D image and then allow them
> to
>> step through the slices. I don't want them to be able to change the
>> orientation. I'm determining the orientation based on a fiducial.
>>>
>>> Can I turn off the plane manipulation and fix the display orientation
>> toward the user? I'll look at vtkImagePlaneWidget a bit more.
>>>
>>> I'm not finding the documentation for vtkImagePlaneWidget2 at
>> http://www.vtk.org/doc/nightly/html/annotated.html. Is it somewhere
>> else?
>>>
>>> Thanks
>>>
>>> -- Scott
>>>
>>> -----Original Message-----
>>> From: Jothy [mailto:jothybasu at gmail.com]
>>> Sent: Tuesday, April 27, 2010 1:44 PM
>>> To: Scott Johnson
>>> Cc: vtkusers at vtk.org
>>> Subject: Re: [vtkusers] Where's my Reslice?
>>>
>>> Either you use vtkImagePlaneWidget or vtkImageplaneWidget2 and get
>>> their output to display on axial,sagittal,coronal.
>>>
>>> Jothy
>>>
>>> On Tue, Apr 27, 2010 at 7:35 PM, Scott Johnson
>>> <Scott.Johnson at neuwave.com> wrote:
>>>> Thanks Jothy,
>>>>
>>>> I'm going to extend the display to oblique angles of the plane. I
>> need the full transform to do that. I'm just using sagittal and
> coronal
>> to get me started.
>>>>
>>>> -- Scott
>>>>
>>>> -----Original Message-----
>>>> From: Jothy [mailto:jothybasu at gmail.com]
>>>> Sent: Tuesday, April 27, 2010 12:28 PM
>>>> To: Scott Johnson
>>>> Cc: vtkusers at vtk.org
>>>> Subject: Re: [vtkusers] Where's my Reslice?
>>>>
>>>> Hi Scott,
>>>>
>>>> You don't need to use the transform for displaying the sagittal and
>>>> coronal views. Just set SetSliceOrientationToYZ &
>>>> SetSliceOrientationToXZ and set slice.
>>>>
>>>> Jothy
>>>>
>>>> On Tue, Apr 27, 2010 at 6:20 PM, Scott Johnson
>>>> <Scott.Johnson at neuwave.com> wrote:
>>>>> Hi Folks,
>>>>>
>>>>>
>>>>>
>>>>> I'm trying to display image planes in a vtkImageViewer2 without
> much
>> luck.
>>>>> My current pipeline looks like:
>>>>>
>>>>>
>>>>>
>>>>> vtkTransform
>>>>>
>>>>> |
>>>>>
>>>>> V
>>>>>
>>>>> vtkDICOMImageReader->vtkImageReslice->vtkImageViewer2
>>>>>
>>>>>
>>>>>
>>>>> If I try to display an Axial slice, it works fine, if I try to
>> display
>>>>> sagittal or coronal slices I don't see the images. If I insert a
>>>>> vtkImageChangeInformation object after the vtkDICOMImageReader, I
>> can see
>>>>> the sagittal and coronal images as well as the axial. This causes
> a
>> problem
>>>>> because I am trying to coordinate other displays with the resliced
>> result.
>>>>> I need to see the images without using the
> vtkImageChangeInformation
>> object.
>>>>>
>>>>>
>>>>>
>>>>> I've tried to explicitly set the bounds on the vtkImageActor
> managed
>> by the
>>>>> vtkImageViewer2, with no luck. I've also tried to place the
>> vtkCamera to
>>>>> point at the center of the plane along the direction of the normal.
>> Didn't
>>>>> work either.
>>>>>
>>>>>
>>>>>
>>>>> There may be a fundamental misunderstanding on my part as to how
>>>>> vtkImageReslice works. I am assuming that the resulting resliced
>> volume
>>>>> would be displayed the same as an axial image, so I am leaving the
>>>>> vtkImageViewer2->SetSliceOrientationXY() and moving between slices
>> with the
>>>>> SetSlice method.
>>>>>
>>>>>
>>>>>
>>>>> The eventual goal is to reslice the image volume at oblique angles,
>> but I
>>>>> figure I'm on the right track if I can get the sagittal and coronal
>> images
>>>>> to display correctly.
>>>>>
>>>>>
>>>>>
>>>>> I'm concerned that vtkImageViewer2 is doing something for me that I
>> don't
>>>>> want it to do. Do I need to manage my own vtkImageActor?
>>>>>
>>>>>
>>>>>
>>>>> A code snippet for the Coronal images follows:
>>>>>
>>>>> (input is the vtkDICOMImageReader)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _transform = vtkTransform::New();
>>>>>
>>>>> _transform->RotateZ(0.0);
>>>>>
>>>>> _transform->RotateX(90.0);
>>>>>
>>>>> _transform->RotateY(0.0);
>>>>>
>>>>>
>>>>>
>>>>> _reslice = vtkImageReslice::New();
>>>>>
>>>>> _reslice->SetOutputDimensionality(3);
>>>>>
>>>>> _reslice->SetResliceTransform(_transform);
>>>>>
>>>>> _reslice->SetInputConnection(input);
>>>>>
>>>>> _reslice->Update();
>>>>>
>>>>>
>>>>>
>>>>> inputData=vtkImageData::SafeDownCast(_reslice->GetInput());
>>>>>
>>>>> inputData->GetCenter(center);
>>>>>
>>>>> _transform->Translate(center[0], center[1], center[2]);
>>>>>
>>>>>
>>>>>
>>>>> _interactor = vtkRenderWindowInteractor::New();
>>>>>
>>>>>
>>>>>
>>>>> _imageViewer = vtkImageViewer2::New();
>>>>>
>>>>> _imageViewer->SetupInteractor(_interactor);
>>>>>
>>>>> _imageViewer->SetSize(400, 400);
>>>>>
>>>>> _imageViewer->SetColorWindow(1024);
>>>>>
>>>>> _imageViewer->SetColorLevel(800);
>>>>>
>>>>> _imageViewer->SetInputConnection(_reslice->GetOutputPort());
>>>>>
>>>>>
>>>>>
>>>>> Any ideas appreciated.
>>>>>
>>>>>
>>>>>
>>>>> Thanks
>>>>>
>>>>>
>>>>>
>>>>> -- Scott
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the VTK FAQ at:
>>>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>
>>>>>
>>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list