Skip to main content

COPEX high rate compression quality metrics

Project description

COPEX High Rate Compression Quality Metrics

This package provides quality metrics for high rate compression.

Installation

pip install COPEX_high_rate_compression_quality_metrics

Library usage

Comparison of Two Multiband TIFF Images via LRSP (L:LPIPS, R:RMSE, S:SSIM, P:PSNR)

the following shows concrete example of use of the library

Steps:

  1. Import necessary libraries
  2. Initialize the model and specify the file paths
  3. Define preprocessing functions
  4. Load the TIFF files
  5. Calculate the metrics

1 Library install / import

use "pip install COPEX-high-rate-compression-quality-metrics" to install the library

# Array handler
import numpy as np
# to have a json formated output
import json
import math
# File handler
from skimage import io

# File path handler
import os

# Metrics and utils
import COPEX_high_rate_compression_quality_metrics.metrics as COPEX_metrics
import COPEX_high_rate_compression_quality_metrics.utils as COPEX_utils

2 LPIPS initialization

# LPIPS initialization
loss_fn = COPEX_metrics.initialize_LPIPS()

3 File path definition

# Specify file paths here
file_path1 = os.path.join('T28PGV_20160318T111102_B04_20m.tif')
file_path2 = os.path.join('T28PGV_20160318T111102_B04_20m_ter.tif')

4 File loading

#load images and show shapes
image1 = io.imread(file_path1)
print(file_path1," [shape =",image1.shape,", min =",np.min(image1), ", max =",np.max(image1), ", dtype = ",image1.dtype,"]")
image2 = io.imread(file_path2)
print(file_path2," [shape =",image2.shape,", min =",np.min(image2), ", max =",np.max(image2), ", dtype = ",image2.dtype,"]")


# checking if images have the same shape
if image1.shape != image2.shape:
    raise ValueError("Les deux images doivent avoir les mêmes dimensions.")
print("images loaded with success.")

File visualization (optional)

COPEX_utils.display_multiband_tiffs(image1, image2)

png

5 metrics calculation

# Calculate all metrics
lpips_values,lpips_value = COPEX_metrics.calculate_lpips_multiband(image1, image2,loss_fn)
mean_ssim = COPEX_metrics.calculate_ssim_multiband(image1, image2)
psnr_value = COPEX_metrics.calculate_psnr(image1, image2)
rmse_value = COPEX_metrics.calculate_rmse(image1, image2)

Results interpretation

see VT-P382-SLD-003-E-01-00_COPEX_DCC_PM3_20230630.pdf for more informations about metrics weeknesses

LPIPS : (identical images) 0 <==========> 1 (completely different images) lower is better [very good LPIPS do not mean that images are not totaly different pixel wise]

RMSE : (identical images) 0 <==========> +inf (completely different images) lower is better [different kind of degradations can give the same score, do not capture blurring]

SSIM : (completely different images) -1 <==========> 1 (identical images) higher is better [sensible to little local distorions, sensible to noise differences]

PSNR : (completely different images) 0 <==========> +inf (identical images) higher is better [sensible to Big local differences]

data = {
    "files paths":{
        "file1":file_path1,
        "file2":file_path2
        },
    "metrics":{
        "LPIPS":lpips_value,
        "RMSE":rmse_value,
        "SSIM":mean_ssim,
        "PSNR":str(psnr_value) if math.isinf(psnr_value) else psnr_value     
    }
}
json_data = json.dumps(data, indent=4)

print(json_data)
    {
        "files paths": {
            "file1": "T28PGV_20160318T111102_B04_20m.tif",
            "file2": "T28PGV_20160318T111102_B04_20m_ter.tif"
        },
        "metrics": {
            "LPIPS": 0.038381848484277725,
            "RMSE": 192.01308995822703,
            "SSIM": 0.9817911582274915,
            "PSNR": 26.491058156522357
        }
    }

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file COPEX_high_rate_compression_quality_metrics-0.0.4.tar.gz.

File metadata

File hashes

Hashes for COPEX_high_rate_compression_quality_metrics-0.0.4.tar.gz
Algorithm Hash digest
SHA256 80f99c04466e2443b77a98a66458e435d96b24e8664d524e4594babf70c466a8
MD5 c89eb191ffc113bff3c79e7e61b93ca6
BLAKE2b-256 9fa5e5a54cce5713ae462ddc4e68737dca1b26b13cce5caa365fc90ac72442d0

See more details on using hashes here.

Provenance

File details

Details for the file COPEX_high_rate_compression_quality_metrics-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for COPEX_high_rate_compression_quality_metrics-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f0c8c0dd56a206e5687f5552299cb0027f6f6aaabf1dd89b835bf7a2cec56806
MD5 e60b4d4f58b815d353d4ab430995e7ec
BLAKE2b-256 b4fcda26429dafae8c579bae8d999c27fec0a1c0465a4c6584453575e5f113cd

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page