Metadata-Version: 2.4
Name: ssimulacra2
Version: 0.2.0
Summary: Python implementation of SSIMULACRA2 image quality metric
Project-URL: Documentation, https://github.com/yourusername/py-ssimulacra2#readme
Project-URL: Issues, https://github.com/yourusername/py-ssimulacra2/issues
Project-URL: Source, https://github.com/yourusername/py-ssimulacra2
Author-email: Pacidus <Pacidus@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2025, Pacidus
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License-File: LICENSE
Keywords: compression,image quality,perception,ssim,ssimulacra2
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Python: >=3.8
Requires-Dist: numpy>=1.19.0
Requires-Dist: opencv-python>=4.11.0
Requires-Dist: pillow>=8.0.0
Requires-Dist: scikit-image>=0.17.2
Requires-Dist: scipy>=1.5.0
Description-Content-Type: text/markdown

# SSIMULACRA2

[![PyPI - Version](https://img.shields.io/pypi/v/ssimulacra2.svg)](https://pypi.org/project/ssimulacra2)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ssimulacra2.svg)](https://pypi.org/project/ssimulacra2)

Python implementation of SSIMULACRA2 (Structural SIMilarity Unveiling Local And Compression Related Artifacts) - a perceptual image quality metric designed to accurately detect compression artifacts.

## Description

SSIMULACRA2 is a full-reference image quality metric that aims to estimate human perception of image quality, specifically focusing on compression artifacts. This Python package provides a clean, efficient implementation that closely follows the original C++ algorithm.

SSIMULACRA2 scores range from 100 (perfect quality) down to negative values (extremely poor quality):

- **negative scores**: extremely low quality, very strong distortion
- **10**: very low quality (average output of cjxl -d 14 / -q 12 or libjpeg-turbo quality 14, 4:2:0)
- **30**: low quality (average output of cjxl -d 9 / -q 20 or libjpeg-turbo quality 20, 4:2:0)
- **50**: medium quality (average output of cjxl -d 5 / -q 45 or libjpeg-turbo quality 35, 4:2:0)
- **70**: high quality (hard to notice artifacts without comparison to the original)
- **80**: very high quality (impossible to distinguish from the original in a side-by-side comparison at 1:1)
- **85**: excellent quality (impossible to distinguish from the original in a flip test at 1:1)
- **90**: visually lossless (impossible to distinguish from the original in a flicker test at 1:1)
- **100**: mathematically lossless

## Installation

```console
pip install ssimulacra2
```

## Usage

### Command Line

```console
# Basic usage
ssimulacra2 original.png compressed.png

# For just the score without interpretation
ssimulacra2 original.png compressed.png --quiet
```

### Python

```python
from ssimulacra2 import compute_ssimulacra2, compute_ssimulacra2_with_alpha

# Basic usage
score = compute_ssimulacra2("original.png", "compressed.png")
print(f"Quality score: {score:.2f}")

# For images with alpha channel (automatically uses both dark and light backgrounds)
score = compute_ssimulacra2_with_alpha("original.png", "compressed.png")
print(f"Quality score with alpha: {score:.2f}")
```

## Features

- **Accurate**: Closely follows the original C++ implementation
- **Alpha Support**: Special handling for images with transparency
- **Multi-scale Analysis**: Examines image quality at multiple resolution scales
- **XYB Color Space**: Uses a perceptual color space for more accurate results
- **Easy to Use**: Simple command-line interface and Python API

## Requirements

- Python 3.8+
- NumPy
- SciPy
- Pillow (PIL)
- scikit-image
- OpenCV

## Performances
Size : **1024x768**

### v0.2.0
```shell
Time (mean ± σ):     671.5 ms ±   8.2 ms    [User: 566.1 ms, System: 100.2 ms]
Range (min … max):   659.6 ms … 683.4 ms    10 runs
```
### v0.1.0
```shell
Time (mean ± σ):     22.447 s ±  0.197 s    [User: 22.263 s, System: 0.069 s]
Range (min … max):   22.186 s … 22.723 s    10 runs 
```

## License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

## Acknowledgements

This implementation is based on the original SSIMULACRA2 algorithm developed for the JPEG XL project.
