Skip to content

Persistence-Driven Compression

Persistence-Driven Compression example
Image

Pipeline description

This example helps comparing three outputs of the TopologicalCompression filter to the original input grayscale image (top-left view in the above screenshot), with the following parameters:

  • ZFP relative error tolerance set to 50%, no topological compression (bottom-left view in the above screenshot),
  • Topological loss set to 10%, no ZFP extra compression (top-right view),
  • Topological loss set to 10% and ZFP relative error tolerance set to 50% (bottom-right view).

Those files have been generated from the original VTI image using the TopologicalCompressionWriter filter. To read them, Paraview uses its counterpart, TopologicalCompressionReader.

ParaView

To reproduce the above screenshot, go to your ttk-data directory and enter the following command:

$ paraview --state=states/persistenceDrivenCompression.pvsm

Python code

This script loads the uncompressed naturalImage_original.vti input file, saves it as in the TTK Topological Compressed Image Data file format, using TopologicalCompressionWriter under the hood. The produced file is then loaded with TopologicalCompressionReader and saved back to VTI. This demonstrates the use of the TopologicalCompression I/O modules.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python

from paraview.simple import *

# read input VTI with 'XML Image Data Reader'
naturalImage = XMLImageDataReader(FileName=["naturalImage_original.vti"])

# compress & save to TTK Topological Compression format
SaveData(
    "naturalImage_persistence10_zfp50.ttk",
    proxy=naturalImage,
    ScalarField=["POINTS", "PNGImage"],
    Topologicallosspersistencepercentage=10,  # Topological loss
    ZFPRelativeErrorToleranceextra=50,  # ZFP Relative Error Tolerance
)

# read the compressed file with 'TTK TopologicalCompressionReader'
naturalImage_compressed = TTKTopologicalCompressionReader(
    FileName="naturalImage_persistence10_zfp50.ttk",
)

# write compressed data-set to VTI
SaveData(
    "uncompressed_naturalImage_persistence10_zfp50.vti",
    naturalImage_compressed,
)

Inputs

  • naturalImage_original.vti: a grayscale picture converted to the VTI format

  • naturalImage_zpf50.ttk: the previous image, compressed using TopologicalCompressionWriter with ZFP compressor only (no topological compression). ZFP relative error tolerance was set to 50%.

  • naturalImage_persistence10.ttk: the first input image, compressed using TopologicalCompressionWriter with a Topological loss of 10% and without ZFP (ZFP relative error tolerance set to a negative value).

  • naturalImage_persistence10_zpf50.ttk: the first input image, compressed using TopologicalCompressionWriter with a Topological loss of 10% and a ZFP relative error tolerance set to 50%.

Outputs

  • uncompressed_naturalImage_persistence10_zfp50.vti: the first input, compressed and saved as a VTI file.

C++/Python API

TopologicalCompression

TopologicalCompressionReader

TopologicalCompressionWriter