Page MenuHomePhabricator

[Segmentation] Accelerate do/undo mechanism for segmentations
Closed, ResolvedPublic


In T28491: [Segmentation] Slice interpolation 'confirm for all slices' sometimes crahes the duration of 2d-interpolations of large segmentations was reduced by an order of magnitude. However, there's potential for another order of magnitude, since the do/undo mechanism involved in applying the interpolation (or any other segmentation tool result) is very slow.

One part of the issue (or 2/3 of the time that is spent) is related to the zlib compression of difference images. This could be greatly reduced by using a suitable modern compression algorithm that is optimized for compression speed, since the data we are talking about is compression-friendly anyways.

Since the bottleneck is memory access in this case, using such a modern compression algorithm could be even faster than doing a plain block copy of uncompressed data.

I suggest LZ4 for this purpose.

The other part of the issue (1/3 of the time that is currently spent) is related to applying the difference image to a segmentation. This can be potentially accelerated with multi-threading.

Revisions and Commits

Restricted Differential Revision
Restricted Differential Revision
Restricted Differential Revision

Event Timeline

kislinsk triaged this task as Normal priority.Jul 5 2021, 10:51 PM
kislinsk created this task.
kislinsk moved this task from Backlog to Segmentation on the MITK (v2021.10) board.

With the same test data as in T28491, I was already able to virtually eliminate the time spent on compression with LZ4.

zlibno compressionLZ4
new ApplyDiffImageOperation (do)9.55s0.38s0.17s
new ApplyDiffImageOperation (undo)9.57s1.48s0.17s

I changed the CompressedImageContainer class to use LZ4 instead of zlib and to compress slice-based instead of 3d-volume-based to keep sizes in a valid range for LZ4 even in huge images.

kislinsk renamed this task from Accelerate do/undo mechanism for segmentations to [Segmentation] Accelerate do/undo mechanism for segmentations.Jul 8 2021, 12:21 PM
kislinsk added a revision: Restricted Differential Revision.

Deleted branch from rMITK MITK: bugfix/T28606-UseLZ4InCompressedImageContainerClass.

Deleted branch from rMITK MITK: bugfix/T28606-StoreImageDimension.