Improved structural similarity metrics for comparing microscopy data.
Project description
MicroSSIM
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
Release history Release notifications | RSS feed
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 microssim-0.0.1.tar.gz
.
File metadata
- Download URL: microssim-0.0.1.tar.gz
- Upload date:
- Size: 5.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f835b075566c6d9953a1d7f8a253865a06306b32e44fdb8ef1663e096cc863ee |
|
MD5 | b8449285e0108c25154fcbb9a29e7d34 |
|
BLAKE2b-256 | 517e1c19efcbc3fb3b9ed547b7bc13ec9973ae306d8511ea5da5165b6449afd7 |
File details
Details for the file microssim-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: microssim-0.0.1-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 333ffb657db6da5107e87cabb8950e0abb85f3542710b3dc2e5d480d83501e51 |
|
MD5 | 52672aa3be6163231df62ff0dc59b152 |
|
BLAKE2b-256 | 8eca0982fc606ae48c9af5c8618b1e5dfe82abb98842df8198d1e80a0d8805a3 |