View Issue Details

IDProjectCategoryView StatusLast Update
0003885Slicer4Core: GUIpublic2017-09-27 14:44
ReporternicoleAssigned Tonicole 
PrioritynormalSeverityminorReproducibilityN/A
Status assignedResolutionopen 
Product Version 
Target VersionbacklogFixed in Version 
Summary0003885: Update qMRMLScreenShotDialog to support high-resolution magnified screenshot
Description

The snapshot image scale slider was added in a previous version of Silcer when we were using VTK calls to capture the window and could do an offscreen buffer rendering at a higher resolution.

Slicer 4.4 uses QPixmap().grabWidget and ctk::grabVTKWidget and neither offer a scaling option. We're currently scaling the captured image of the widget using QImage scale after the fact. This seems equivalent to what a user would do if they needed larger images.

Additional Information

The current code in the scripted module template isn't doing the scaling step. The self test image scale slider value is just being passed through in the creation of the snapshot node, but it doesn't reflect the scale factor of the image passed to the node creation method.
The QImage scale call can be added, but some investigation should be made to ensure that it's worthwhile.

TagsNo tags attached.

Relationships

related to 0001662 acknowledgednicole Expand scene snapshot support for more layouts 
has duplicate 0003858 closednicole Scale factor is broken when saving screenshots 
has duplicate 0002898 closednicole Restore screenshot resolution for VTK render view 

Activities

nicole

nicole

2015-09-08 10:30

administrator   ~0013260

Last edited: 2015-09-08 10:32

In previous versions we used vtkWindowToImageFilter, but in the VTK 6 examples, it's ifdef'd out for versions higher than 5. vtkRenderLargeImage seems to be the replacement, but I'm seeing tiling artifacts when using it to capture the 3d window:

lm = slicer.app.layoutManager()
td = lm.threeDWidget(0)
threeDView = td.threeDView()
rw = threeDView.renderWindow()
col = rw.GetRenderers()
ren = col.GetItemAsObject(0)
renderLargeImage = vtk.vtkRenderLargeImage()
renderLargeImage.SetInput(ren)
renderLargeImage.SetMagnification(10)
writer = vtk.vtkPNGWriter()
writer.SetInputConnection(renderLargeImage.GetOutputPort())
writer.SetFileName('Mag-test.png')
writer.Write()

Results in tiling in the default background, but only in one dimension (if use the black background, you can't tell).

2015-09-08 10:30

 

Mag-test.png (1,575,203 bytes)
Mag-test.png (1,575,203 bytes)
nicole

nicole

2015-09-10 07:31

administrator   ~0013269

Bug report submitted to VTK:
http://www.vtk.org/Bug/view.php?id=15715

2015-10-27 15:31

 

2015-10-27 15:39

 

nicole

nicole

2015-10-27 15:39

administrator   ~0013439

Can ask the user if they wish to continue with the tiling problem.

Render large image results in errors with the 2d windows (imperfect tiling), see RedSliceMagnification3.png

Using the window to image filter on 2d windows results in tiling the image when scaled, see RedSliceWindowToImageScale3.png

jcfr

jcfr

2015-10-28 11:40

administrator   ~0013452

Last edited: 2015-10-28 11:40

Hi Nicole,

Thanks to Max, we now have a fix ready for testing: https://gitlab.kitware.com/vtk/vtk/merge_requests/841

Could you also create an account on gitlab.kitware.com ? That would allow you to share feedback more easily.

Since the plan would be to integrate the fix into Slicer/VTK fork. Would be ideal if you could test this afternoon :)

Thanks
Jc

nicole

nicole

2015-10-28 11:47

administrator   ~0013453

Linked my github account into gitlab.kitware, testing now!

nicole

nicole

2015-10-28 11:59

administrator   ~0013454

Works for me!
The CTK grabWidget methods are still using QImages and scaling those, what I tested was redoing the snapshot logic in Slicer to use render large image just for the 3D window only case.
The snapshot logic still needs to be redone to support arbitrary layouts (bug 1662), but this will allow higher res 3D window captures at least.

jcfr

jcfr

2015-10-28 13:31

administrator   ~0013455

Fixed in r24668

See http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=24668

nicole

nicole

2015-10-28 13:35

administrator   ~0013456

Not quite yet, I have to check in the code that uses it. Updating my branch and last compile check being done now!

jcfr

jcfr

2015-10-28 13:42

administrator   ~0013457

Last edited: 2015-10-28 13:42

Good point. I updated the title.

nicole

nicole

2015-10-28 13:51

administrator   ~0013458

And for clarity: this will only fix the scaling on the 3D window, the 2D windows still have tiling problems.

jcfr

jcfr

2015-10-28 14:00

administrator   ~0013459

Could you create an other VTK issue mentioning that tiling with a renderer having multiple viewport doesn't work ?

nicole

nicole

2015-10-28 14:08

administrator   ~0013460

Pull request:
https://github.com/Slicer/Slicer/pull/388

I'll work on an example and submit a but report to the VTK tracker for the 2d case (not sure if it's viewport related, the tiling seen in the attached image on this bug is just from a single slice shown in the Red slice viewer, no lightbox mode enabled).

jcfr

jcfr

2015-10-28 14:23

administrator   ~0013462

I'll work on an example and submit a but report to the VTK tracker for the 2d
case (not sure if it's viewport related, the tiling seen in the attached image
on this bug is just from a single slice shown in the Red slice viewer, no
lightbox mode enabled).

Thanks for clarifying.

If you have a short python script reproducing the problem in Slicer, Max could probably help.

nicole

nicole

2015-10-28 14:43

administrator   ~0013463

Last edited: 2015-10-28 14:45

This produces the same type of image attached to this bug as RedSliceMagnification3.png:

import SampleData
sampleDataLogic = SampleData.SampleDataLogic()
head = sampleDataLogic.downloadMRHead()
lm = slicer.app.layoutManager()
redWidget = lm.sliceWidget("Red")
redView = redWidget.sliceView()
rw = redView.renderWindow()
rens = rw.GetRenderers()

note there are 2 renderers in the collection, using the first one (second one produces same image)

ren = rens.GetItemAsObject(0)
renderLargeImage = vtk.vtkRenderLargeImage()
renderLargeImage.SetInput(ren)
renderLargeImage.SetMagnification(3)
renderLargeImage.Modified()
writer = vtk.vtkPNGWriter()
writer.SetInputConnection(renderLargeImage.GetOutputPort())
writer.SetFileName('RedSliceView-RenderLargeImage-3.png')
writer.Write()

jcfr

jcfr

2015-10-28 15:51

administrator   ~0013464

Support for high-resolution 3D screenshot integrated in r24670
See http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=24670

lassoan

lassoan

2017-09-27 14:44

developer   ~0015201

It seems that the created screenshots are still not truly high-resolution (there are identical pixels in the output image, so it looks like the original resolution image was just resampled restrospectively).

Issue History

Date Modified Username Field Change
2014-11-06 09:32 nicole New Issue
2014-11-06 09:32 nicole Status new => assigned
2014-11-06 09:32 nicole Assigned To => nicole
2014-12-30 10:42 nicole Relationship added related to 0003858
2015-09-01 10:20 nicole Target Version Slicer 4.4.1 => Slicer 4.5.0-1
2015-09-08 10:30 nicole Note Added: 0013260
2015-09-08 10:30 nicole File Added: Mag-test.png
2015-09-08 10:31 nicole Note Edited: 0013260
2015-09-08 10:32 nicole Note Edited: 0013260
2015-09-10 07:31 nicole Note Added: 0013269
2015-09-10 07:32 nicole Relationship added has duplicate 0002898
2015-10-27 11:14 nicole Relationship replaced has duplicate 0003858
2015-10-27 15:31 nicole File Added: RedSliceMagnification3.png
2015-10-27 15:39 nicole File Added: RedSliceWindowToImageScale3.png
2015-10-27 15:39 nicole Note Added: 0013439
2015-10-28 11:40 jcfr Note Added: 0013452
2015-10-28 11:40 jcfr Note Edited: 0013452
2015-10-28 11:47 nicole Note Added: 0013453
2015-10-28 11:59 nicole Note Added: 0013454
2015-10-28 11:59 nicole Relationship added related to 0001662
2015-10-28 13:31 jcfr Note Added: 0013455
2015-10-28 13:31 jcfr Status assigned => resolved
2015-10-28 13:31 jcfr Fixed in Version => Slicer 4.5.0-1
2015-10-28 13:31 jcfr Resolution open => fixed
2015-10-28 13:35 nicole Note Added: 0013456
2015-10-28 13:35 nicole Status resolved => assigned
2015-10-28 13:36 nicole Resolution fixed => open
2015-10-28 13:41 jcfr Summary Fix or disable scaling of snapshots => Update snapshot to support scaling
2015-10-28 13:42 jcfr Note Added: 0013457
2015-10-28 13:42 jcfr Note Edited: 0013457
2015-10-28 13:51 nicole Note Added: 0013458
2015-10-28 14:00 jcfr Note Added: 0013459
2015-10-28 14:08 nicole Note Added: 0013460
2015-10-28 14:23 jcfr Note Added: 0013462
2015-10-28 14:43 nicole Note Added: 0013463
2015-10-28 14:43 nicole Note Edited: 0013463
2015-10-28 14:45 nicole Note Edited: 0013463
2015-10-28 15:50 jcfr Fixed in Version Slicer 4.5.0-1 =>
2015-10-28 15:50 jcfr Target Version Slicer 4.5.0-1 => Slicer 4.5.1
2015-10-28 15:50 jcfr Summary Update snapshot to support scaling => Update qMRMLScreenShotDialog to support high-resolution magnified screenshot
2015-10-28 15:51 jcfr Note Added: 0013464
2016-10-12 02:31 jcfr Target Version Slicer 4.5.1 => Slicer 4.7.0
2017-09-27 14:44 lassoan Target Version Slicer 4.7.0 => backlog
2017-09-27 14:44 lassoan Note Added: 0015201