fit to screen in vtkImageViewer2 + QVTKWidget

classic Classic list List threaded Threaded
4 messages Options
ran
Reply | Threaded
Open this post in threaded view
|

fit to screen in vtkImageViewer2 + QVTKWidget

ran
Hello,
Using  vtkImageViewer2 + QVTKWidget and vtkInteractorStyleImage, I created a DICOM image viewer.  But the image mot filling to the the entire viewport.  I need the fit the image to the viewport. For this I tried different suggestion available online, but no effect, 
like 
    m_vtkImViewer->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
    m_vtkImViewer->GetRenderer()->GetActiveCamera()->SetParallelScale(1000);

    m_vtkImViewer->GetRenderer()->GetActiveCamera()->Dolly(10);

   
    m_vtkImViewer->GetRenderWindow()->SetSize(50, 50);

Please help to fit the image in window.
Screenshot of current viewer is attached. 
As shown in the screnshot the image is displaying within a margin inside the viewport.
But the corner annotations (set using vtkCornerAnnotation) are set in corners of the view port.   

_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers

Untitled.jpg (227K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: fit to screen in vtkImageViewer2 + QVTKWidget

Bill Lorensen

On Jul 26, 2017 6:36 AM, "K O ranjith" <[hidden email]> wrote:
Hello,
Using  vtkImageViewer2 + QVTKWidget and vtkInteractorStyleImage, I created a DICOM image viewer.  But the image mot filling to the the entire viewport.  I need the fit the image to the viewport. For this I tried different suggestion available online, but no effect, 
like 
    m_vtkImViewer->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
    m_vtkImViewer->GetRenderer()->GetActiveCamera()->SetParallelScale(1000);

    m_vtkImViewer->GetRenderer()->GetActiveCamera()->Dolly(10);

   
    m_vtkImViewer->GetRenderWindow()->SetSize(50, 50);

Please help to fit the image in window.
Screenshot of current viewer is attached. 
As shown in the screnshot the image is displaying within a margin inside the viewport.
But the corner annotations (set using vtkCornerAnnotation) are set in corners of the view port.   

_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
ran
Reply | Threaded
Open this post in threaded view
|

Re: fit to screen in vtkImageViewer2 + QVTKWidget

ran
Thanks for the solution, 
One more doubt in my application, vtkDICOMImageReader is used for reading all the DICOM files in a folder and setting directly to vtkImageViewer2  through SetInputConnection(reader->GetOutputPort());. The DICOM images in the folder might have different size. In this case how can get "Extent" "Orgin" "spacing" parameters of each image.
Have any methods to extract these from  vtkDICOMImageReader  or vtkImageViewer2 ?

On Wed, Jul 26, 2017 at 5:16 PM, Bill Lorensen <[hidden email]> wrote:

On Jul 26, 2017 6:36 AM, "K O ranjith" <[hidden email]> wrote:
Hello,
Using  vtkImageViewer2 + QVTKWidget and vtkInteractorStyleImage, I created a DICOM image viewer.  But the image mot filling to the the entire viewport.  I need the fit the image to the viewport. For this I tried different suggestion available online, but no effect, 
like 
    m_vtkImViewer->GetRenderer()->GetActiveCamera()->ParallelProjectionOn();
    m_vtkImViewer->GetRenderer()->GetActiveCamera()->SetParallelScale(1000);

    m_vtkImViewer->GetRenderer()->GetActiveCamera()->Dolly(10);

   
    m_vtkImViewer->GetRenderWindow()->SetSize(50, 50);

Please help to fit the image in window.
Screenshot of current viewer is attached. 
As shown in the screnshot the image is displaying within a margin inside the viewport.
But the corner annotations (set using vtkCornerAnnotation) are set in corners of the view port.   

_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: fit to screen in vtkImageViewer2 + QVTKWidget

Andaharoo
This post was updated on .
In reply to this post by ran
Hi,
I can't say why it does this but I've battled this effect by doing the following with parallel scale defined as half the size of the image. I usually do something like this:

extent = new double[3]
{
        image->GetDimensions()[0] * image->GetSpacing()[0] * 0.5,
        image->GetDimensions()[1] * image->GetSpacing()[1] * 0.5,
        image->GetDimensions()[2] * image->GetSpacing()[2] * 0.5
};

imageViewer->GetRenderer()->ResetCamera();
vtkCamera* cam = imageViewer->GetRenderer()->GetActiveCamera();
cam->ParallelProjectionOn();
cam->SetParallelScale(extent[0]);

This gets a little more complicated if you want to use a different orientation though. Here's some psuedo

if (XY orientation)
    SetParallelScale(extent[0]);
    cam->SetViewUp(0, 1, 0);
else if (YZ orientation)
    SetParallelScale(std::max(extent[1], extent[2] * h / w))
    cam->SetViewUp(0, 0, 1);
else if (XZ orientation)
    SetParallelScale(std::max(extent[0], extent[2] * h / w));
    cam->SetViewUp(0, 0, 1);

Where h/w height and width can be gotten from imageViewer->GetRenderer()->getSize()