Skip to main content

Improved structural similarity metrics for comparing microscopy data.

Project description

MicroSSIM

License PyPI Python Version CI codecov

MicroSSIM is an image measure aimed at addressing the shortcomings of the Structural Similarity Index Measure (SSIM), in particular in the context of microscopy images. Indeed, in microscopy, degraded images (e.g. lower signal to noise ratio) often have a different dynamic range than the original images. This can lead to a poor performance of SSIM.

The measure normalizes the images using background subtraction and a more appropriate range estimation. It then estimates a scaling factor used to scale the image to the target (original image or ground truth). The metric is then computed similarly to the SSIM.

MicroSSIM is easily extensible to other SSIM-like measures, such as Multi-Scale SSIM (MS-SSIM), for which we provide an example.

See the paper for more details.

Installation

pip install microssim

Usage

import numpy as np
from microssim import MicroSSIM, micro_structural_similarity
from skimage.metrics import structural_similarity

rng = np.random.default_rng(42)
N = 5
gt = 200 + rng.integers(0, 65535, (N, 256, 256)) # stack of different images
pred = rng.poisson(gt) / 10

# using the convenience function
result = micro_structural_similarity(gt, pred)
print(f"MicroSSIM: {result} (convenience function)")

# using the class allows fitting a large dataset, then scoring a subset
microssim = MicroSSIM()
microssim.fit(gt, pred) # fit the parameters

for i in range(N):
    score = microssim.score(gt[i], pred[i]) # score a single pair
    print(f"MicroSSIM ({i}): {score}")

# compare with SSIM from skimage
for i in range(N):
    score = structural_similarity(gt[i], pred[i], data_range=65535)
    print(f"SSIM ({i}): {score}")

The code is similar for MicroMS3IM.

Tips for deep learning

MicroSSIM was developed in the context of deep-learning, in which SSIM is often used as a measure to compare denoised and ground-truth images. The tips presented here are valid beyond deep-learning.

The larger the dataset, the better the estimate of the scaling factor will be. Therefore, it is recommended to fit the measure on the entire dataset (e.g. the whole training dataset). Once the data fitted, the MSSIM class has registered the parameters used for normalization and scaling. You can then score a subset of the data (e.g. the validation or test datasets) using the score method.

Cite us

If you use MicroSSIM in your research, please cite us:

Ashesh, Ashesh, Joran Deschamps, and Florian Jug. "MicroSSIM: Improved Structural Similarity for Comparing Microscopy Data." arXiv preprint arXiv:2408.08747 (2024). link.

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

microssim-0.0.3.tar.gz (5.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

microssim-0.0.3-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file microssim-0.0.3.tar.gz.

File metadata

  • Download URL: microssim-0.0.3.tar.gz
  • Upload date:
  • Size: 5.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for microssim-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ad7817d76ca851b7b28d265eb7931756d64e308bcb9040b316006857d2d0b240
MD5 16b4a87de181e7ae8ffd61cf158de36a
BLAKE2b-256 f97c0f66f7f41af777d30cbe15951dfcf1a8ea34cdf6a2871679026cd8b62c3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for microssim-0.0.3.tar.gz:

Publisher: ci.yml on juglab/MicroSSIM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file microssim-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: microssim-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for microssim-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 753acb31a22db252ab79cbd5816c5dc56a31a3e29628f83cb205e0722446fcbe
MD5 3f44360b965e7b57ef8581a78fd6388d
BLAKE2b-256 d7235022d1ecd3585088349443a57e260743fb2e6997eaf27bb58ce9ba2f95ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for microssim-0.0.3-py3-none-any.whl:

Publisher: ci.yml on juglab/MicroSSIM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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