Page MenuHomePhabricator

Improve performance of ImageVtkMapper2D
Closed, ResolvedPublic


There are lots of possibilities to improve the performance of the new ImageVtkMapper2D:
-The method ComputeClippedPlaneBounds is called everytime. But in most cases we just want to slice paraxial through an image. In this common case the Geoemtry of the 2D slice can be used instead of this method.
-The reslicing (and other things) is performed everytime during the rendering process. Meaning that we reslice the data even if just zoom or color the image. The update method could be optimized with respect to performance.

Because the 2D rendering is performed three times in our rendering pipeline this could increase the performance of MITK significantly.

Event Timeline

Another great performance improve would be to use the complete actor(s) generated in the mitkImageVtkMapper2D inside the Geometry2DDataVtkMapper3D to render them in 3D. Currently, the image is passed and a lot of actions are re-executed there to render the same as in 2D. This is unnecessary work.

Resetting all bugs without active assignee flag to "CONFIRMED". Change status to IN_PROGRESS if you are working on it.

We already re-use the properties from the ImageVtkMapper2D in the Geometry2DDataVtkMapper3D as mentioned in my second post.

Easy TODOs:
-Double check if the reslicing is performed when zooming or panning are done (should not be the case)
-check if the reslicing is necessary if the level window, color, opacity, or other properties are changed

TODO Markus & Geometry team:
-Is it possible to distinguish between to different modes (par-axial or arbitrary slices) for better performance? In other words: Do we need to call the method ComputeClippedPlaneBounds even if the reslice par-axial without any rotation as mentioned here:

-The method ComputeClippedPlaneBounds is called everytime. But in most cases we
just want to slice paraxial through an image. In this common case the Geoemtry
of the 2D slice can be used instead of this method.

Easy Todo (1): done, reslicing is not performed
Easy Todo (2): Reslicing is performed, when modifying the level window, even if it is not needed. We commented out the method Modified() from the GenerateData() of ImageVTKMapper2D, but the LevelWindow-Filter does then not react on changes of the LevelWindow property anymore.

All done:

fixed levelwindow filters to respect modified time of their associated lookuptable. so now reslicing is only done, when reslicer parameters are changes
checked with levelwindow/color/opacity property

par-axial optimizations are already include in the vtkImageReslice.
Generating a special case for ComputeClippingBounds is not really important, since it doesnt take that much CPU time

Still to do:

need to integrate with personal branch of Daniel Maleike and finally into the master.

New Todos:

  • integrate vtkMitkLevelWindowFilter and vtkMitkApplyLevelWindowToRGBFilter into one
  • in vtkMitkLevelWindowFilter rethink lookupTable->MapValue( ), this call is much too expensive in terms of cpu usage

After that testing and merging with master

Due to its severity, this bug is considered relevant for the upcoming 2012.09 release.

Please check the status and consider fixing this bug for 2012.09.

What is the current status of this bug?

New remote branch pushed: bug-8165-mastermerge2

Eric, after calling Markus F., I pushed a branch personal/maleike/bug-8165-fast-and-correct-imagemapper-2D., which fixes the performance of rendering during level/window changes. Without this fix it was unbearably slow to change contrast on CR images. (Now we need to think about an artificial slowdown for CT images).

I'll call you about how we integrate this branch.

The whole problem and the fix I made can be summarized to this:

  • with the changes of T8165, there was a bottleneck in rendering, when vtkTexture::IsTranslucent is called. This is done as normal part of rendering to determine if an actor IS translucent
  • IsTranslucent is implemented (on VTK side) in a very correct but extremely slow manner: every pixel value was transformed via the lookup table to see whether it would turn out opaque or not. This would be done with about EVERY frame during level/window changes
  • The result of calling IsTranslucent is constant in our use case of image rendering. All calls to that function (seem to?) result in a return value of 0.
  • I created a subclass of vtkTexture which returns 0 immediately
  • When this class is used in mitk::ImageVtkMapper2D and in mitk::Geometry2DDataVtkMapper3D. rendering speed is improved by a magnitude. I cannot find any visual rendering problems, so this seems a good solution.

From what Markus told me everything would be ready to be integrated..

Thanks for taking care of this! Should we ask the VTK developers if they observed similar behavior or is this just related to our personal RGB-A level-window filter?

New remote branch pushed: bug-8165-level-window-optimizations-testing

There are problems with rendering 2D JPG images in the branch above as well as in personal/maleike/bug-8165-fast-and-correct-imagemapper-2D on which the above branch is based.

It does not look good enough for integration into the Christmas release and needs more testing/fixes.

Please use the branch


for further fixes and testing since it is based on the current master and merging was not trivial.

Changed Target Milestone to next release. This fix is important and should definitely be included in the first release next year.

New remote branch pushed: bug-8165-mastermerge3

New remote branch pushed: bug-8165-mastermerge4

(In reply to comment #16)

New remote branch pushed: bug-8165-mastermerge4

Before requesting the Needs_Core_Modification flag, could you please comment on what has changed since Sascha's comment 13?

Also, given the amount of work here, I think the class (=header) documentation for mitkImageVtkMapper2D could need an update regarding the internals, esp. why/how the new L/W-Filter is used.

New remote branch pushed: bug-8165-mastermerge5

Changes since Sascha's comment:

  • Fixed crash, there was an invalid pointer increment in the mitkLevelWindowFilter.
  • Changed LevelWindowFilter to also accept vtkScalarsToColors (previously only the sub class vtkLookupTable was supported), so that the filter can also apply ColorTransferFunctions.
  • Integrated with latest master.
  • Code again reviewed

New remote branch pushed: bug-8165-mastermerge6

[4de72c]: Merge branch 'bug-8165-mastermerge6'

Merged commits:

2013-02-15 16:00:35 Sandy Engelhardt [ce7428]
Merge branch 'bug-8165-mastermerge5' into bug-8165-mastermerge6


2013-02-15 13:18:54 Sandy Engelhardt [6b9e7c]
Delete comment and replace MITK_Error message by MITK_WARN

2013-02-13 16:45:21 Sandy Engelhardt [609650]
added documentation/fixed merging

2013-02-13 15:54:17 Sandy Engelhardt [1f7e2a]
Merge branch 'bug-8165-mastermerge4' into bug-8165-mastermerge5


2013-02-13 15:16:18 Sandy Engelhardt [d4a455]
fixed tabs

2013-02-13 14:21:09 Sandy Engelhardt [70a6ce]
Made Levelwindowfilter working with color transfer functions property

2013-02-06 16:57:15 Sandy Engelhardt [783759]
fixed binary images

2013-02-06 15:29:21 Sandy Engelhardt [89ab2a]
Reviewed Code / added missing comments and descriptions

2013-02-06 13:40:51 Sandy Engelhardt [65cc97]
Merge branch 'bug-8165-mastermerge3' into bug-8165-mastermerge4

2013-01-09 16:13:54 Eric Heim [3baca1]
fixed wrong opacity on cr images

2013-01-09 15:59:22 Eric Heim [404c12]
fixed rendering of rgba images

2013-01-09 14:26:30 Markus Fangerau [2eb91d]
Merge branch 'bug-8165-level-window-optimizations-testing' into bug-8165-mastermerge3

2012-11-27 16:05:56 Sascha Zelzer [8cd8c5]
Merge remote-tracking branch 'origin/personal/maleike/bug-8165-fast-and-correct-imagemapper-2D' into personal/zelzer/bug-8165-level-window-optimizations-for-christmas-release


2012-11-22 19:44:12 Daniel Maleike [c12bd5]
Implement and register replacement vtkTexture

2012-09-20 11:08:22 Anja Groch [f79a09]
Commit to safe local changes.

2012-08-15 16:12:56 Markus Fangerau [a63f75]
working version

2012-08-01 17:00:39 Markus Fangerau [3b998f]
build fixes

2012-08-01 15:45:46 Anja Groch [af4afb]
Merge remote-tracking branch 'remotes/origin/bug-8165-imageMapper2D-cleanup' into bug-8165-integration-imageMapper2D


2012-07-18 16:27:47 Markus Fangerau [eb0c85]

2012-05-02 17:20:32 Markus Fangerau [58dc20]

2012-05-02 16:02:35 Markus Fangerau [3347e7]
thickslices fix

2012-05-02 14:18:24 Markus Fangerau [ba3811]
Merge branch 'bug-8165-imageMapper2D-optimization' into bug-8165-mastermerge


2012-04-18 16:49:36 Anja Groch [829755]
Fixed update bug; no unnecessary reslicing.

2012-04-06 14:42:22 Anja Groch [83d141]
safety commit

2012-03-07 17:50:00 Daniel Maleike [5cc568]
Now working

rgb, rgba, binary images

2012-03-07 16:07:33 Daniel Maleike [f9b453]
make aplication of LUT and L/W work with basic images

2012-02-29 18:39:53 Daniel Maleike [958265]
Zwischenstand von heute


  • texture-lut klaren, ist noch inkonsistent
  • lw/lut richtig anwenden
  • opacity klaren
  • rendering von binaries und rgb prufen
  • diffusionszeug gucken

New remote branch pushed: bug-8165-cosmetics

[ba5a00]: Merge branch 'bug-8165-cosmetics'

Merged commits:

2013-02-20 14:00:00 Sandy Engelhardt [1575bc]
removed redundant source via shared header between ImageVtkMapper2D and ExtractSliceFilter

reopened because of following introduced bugs:

  • T14551: binary lookuptable was broken on mac
  • strange noise on images with an attached colortransferfunction: colortransferfunction lookup was not threadsafe
  • property "outlook binary" was properly read in the mitkGeometry2DVtkMapper3D

New remote branch pushed: bug-8165-post-bugfixes

[c0afba]: Merge branch 'bug-8165-post-bugfixes'

Merged commits:

2013-02-26 09:22:44 Sandy Engelhardt [73b324]

2013-02-25 17:22:04 Markus Fangerau [b55ca5]
wrong order at building binary lookuptable

2013-02-25 15:02:46 Sandy Engelhardt [b25760]
fixed outline binary in 3D

2013-02-20 15:58:11 Sandy Engelhardt [51e74a]
Adding Opacity Property to PointSetMapper3D

reopening for fixing memory leak

New remote branch pushed: bug-8165-MemoryLeakInImageVtkMapper2D

[7d0382]: Merge branch 'bug-8165-fix-gcc412-compile-errors'

Merged commits:

2013-03-07 17:55:20 Sascha Zelzer [91f8d3]
Fixed implicit conversion errors with gcc 4.1.2.

2013-03-07 17:55:02 Sascha Zelzer [932bb1]
Added missing newline at end of file.

[93f512]: Merge branch 'bug-8165-MemoryLeakInImageVtkMapper2D'

Merged commits:

2013-03-01 12:30:10 Alfred Franz [ccd508]
Closed memory leak by converting normal pointer to vtkSmartPointer

2013-03-01 12:29:32 Alfred Franz [0f9e00]
Extended vtkMitkLevelWindowFilter for use of vtkSmartPointers

2013-02-26 19:37:36 Alfred Franz [31d92b]
Merge branch 'bug-14587-UltrasoundPluginListBug'

Talked with alfred and markus -> this bug can be closed