# isr Image quality assessment: a subjective study with 202 participants, the objective full-reference IQA metrics it is compared against, and the fusion pipelines that predict MOS from those metrics. ## What it is The work has three parts, and they live in three directories. **`metrics/objective/full_reference/`** — full-reference IQA metrics implemented in Python, in eleven modules: `color.py`, `frequency.py`, `gradient.py`, `information.py`, `perceptual.py`, `pixel.py`, `psnr.py`, `region.py`, `ssim.py`, `structural.py`, `wavelet.py`. Each exposes a `compute_all` that takes a reference and a distorted image and returns a dict of scores: PSNR and PSNR-B (`pixel.py`), SSIM, MS-SSIM, CW-SSIM, G-SSIM, W-SSIM, IW-SSIM, FSIM, R-SSIM, GMS+CMS (`ssim.py`, `structural.py`, `gradient.py`), and the information- and frequency-domain families (`information.py`, `frequency.py`, `wavelet.py`). The images themselves are **not** in the repository — only the metric values already computed from them (`data/`). **`metrics/subjective/`** — the study. `pre_processing.py` exports four tables from PostgreSQL (the connection string is built from `ISR_DB_PASSWORD`, see *Requirements*); `post_processing.py` and `compute_mos.py` turn the ratings into a MOS per image (555 images, 12 775 ratings); `anova.py` residualises the demographic bias out of the MOS and runs the ANOVA on what is left. `anonymise_tables.py` is the script that pseudonymised the participant tables — see *License* and `metrics/subjective/tables/DATA-SOURCES.md`. **`scripts/`** — `compute_objective.py` walks reference/distorted pairs and writes the metric values to CSV; `full_ref_analysis.py` correlates each metric with the MOS (PLCC, SRCC, MSE, MAE — the output is `results/iqa_correlation/train/correlation_results.csv`, with ranked scatter plots in the same directory); `pipeline_fusion.py` (830 lines) fuses the full-reference metrics into a regressor that predicts MOS, with Optuna tuning, k-fold selection and pseudo-MOS generation; `compute_subjective.py` ties the subjective side together. ## Requirements - Python 3 with `pip`. The `requirements.txt` lists the 17 packages the code actually imports: `catboost`, `joblib`, `lightgbm`, `matplotlib`, `numpy`, `optuna`, `pandas`, `psycopg2-binary`, `PyWavelets`, `scikit-image`, `scikit-learn`, `scipy`, `seaborn`, `sewar`, `shap`, `statsmodels`, `xgboost`. They are not pinned on purpose — see the header of that file. - **The subjective analysis needs only part of that list.** `compute_mos.py` and `anova.py` run on `numpy`, `pandas`, `scipy`, `scikit-learn`, `statsmodels`, `seaborn` and `matplotlib`. `torch`, `catboost`, `xgboost`, `lightgbm`, `optuna`, `shap`, `sewar`, `scikit-image` and `PyWavelets` are for the objective metrics and the fusion pipelines, and are several GB. - `pre_processing.py` needs a reachable PostgreSQL with the study tables, and the password in the environment: ```bash export ISR_DB_PASSWORD='' python metrics/subjective/pre_processing.py ``` The password is not in the code and there is no default: without the variable the script stops with a `RuntimeError`. - `compute_objective.py` and `pipeline_fusion.py` need the image corpus, which is not distributed here. ## Install / Build ```bash # canonical copy on the self-hosted Gitea (aneto/isr), mirrored to GitHub: git clone https://github.com/ags-neto/isr.git cd isr python3 -m venv ~/.venvs/isr ~/.venvs/isr/bin/python -m pip install -r requirements.txt ``` For the subjective analysis only, the light subset is enough and installs in a minute: ```bash ~/.venvs/isr/bin/python -m pip install numpy pandas scipy scikit-learn statsmodels seaborn matplotlib ``` Nothing needs to be built and there is no GPU requirement. The environment used to produce the published results is described in the report, not fixed here. ## Usage ```bash # MOS per image (555 images) from the anonymised study tables python metrics/subjective/compute_mos.py # -> results/webapp/detailed_mos.csv # debiased MOS + ANOVA + the significance table and the plots python metrics/subjective/anova.py # -> results/pipeline_unbias/tests_debiased.csv # -> results/pipeline_unbias/anova_significance.csv # -> the five .png in results/pipeline_unbias/, and mos_debiased.csv under data/ # objective metrics over a corpus of reference/distorted pairs (needs the images) python scripts/compute_objective.py # the fusion pipeline: tune, select k, predict MOS (needs the images and the heavy deps) python scripts/pipeline_fusion.py fuse --iqa-train data/labeled/train/iqa.csv \ --iqa-distorted data/distorted/iqa.csv --out results/pipeline_fusion ``` ## Tests ```bash ./tests/run.sh ``` `tests/run.sh` exits non-zero when anything fails. It checks, without a GPU and without the database: | Check | Expectation | |---|---| | index is free of environment junk | no `.local/`, `__pycache__` or `.pyc` among the tracked files | | `.gitignore` | excludes `.local/` | | study table shape | 202 participants, 202 sessions, 12 775 ratings | | `age` column, study tables | only labels (`<18`, `18-24`, …, `65+`) — **never** a raw number | | `age` column, `tests.csv` | only the age groups `anova.py` uses (`<18`, `18-25`, `26-35`, `36-50`, `51+`) — **never** a raw number | | identifiers | every participant/session id is a pseudonym (`U` + 10 hex) | | join key | `app_ss_test.session_id` joins `app_ss_session.id`, 202/202 | | secrets | no tracked file has a literal `password=`, an `sk-…` key, an AWS key, a private key or a database URL that carries a password inline | | licence scope | `LICENSE-NOTES.md` lists 9 files and all 9 exist | | analysis | `compute_mos.py` yields 555 images and accounts for all 12 775 ratings | | analysis | `anova.py` reproduces `tests_debiased.csv`, tolerance `max|dif| ≤ 1e-9` (measured: **0**) | The reproducibility claim is not "approximate". Re-running the debiasing on the tables as they are published reproduces the committed results to floating-point precision: `MOS_debiased` in `tests_debiased.csv` to `max|dif| = 2.5e-12`, and `data/labeled/train/mos_debiased.csv` to `max|dif| = 4.9e-13` — i.e. **~1e-12**, the limit of the arithmetic, not a loosened tolerance. What the tests **do not** run, and why: | Not run | Why | |---|---| | `scripts/compute_objective.py` | needs the image corpus (not in the repository) and `scikit-image` / `PyWavelets` / `sewar` | | `scripts/pipeline_fusion.py` | needs the images plus `torch`, `catboost`, `xgboost`, `lightgbm`, `optuna`, `shap` — several GB | | `metrics/subjective/pre_processing.py` | needs a live PostgreSQL and `ISR_DB_PASSWORD` (and `psycopg2-binary`) | Those are reported as **not run**, never as passed. The two analysis checks that do run (`compute_mos.py`, `anova.py`) skip cleanly if `pandas` is not installed, and say so. Nine of the checks are **negative**: they reintroduce the defect in a throwaway fixture — a `.pyc` back in the index, a `.local/` path, an `age` of `9`, a literal password, an OpenAI/AWS/private key, a password-bearing URL, a `LICENSE-NOTES.md` without the nine entries — and require the check to fail on it. One more negative pins the opposite: a `password = os.environ.get(...)` must **not** be reported as a secret. ## Structure ``` metrics/objective/full_reference/ 11 modules of full-reference IQA metrics metrics/subjective/ study: DB export, MOS, ANOVA, anonymisation metrics/subjective/tables/ the study tables (anonymised) + DATA-SOURCES.md scripts/ objective metrics, correlation, fusion pipelines data/ metric values and MOS per split (no images) results/iqa_correlation/train/ metric-vs-MOS correlations, ranked scatter plots results/pipeline_noreference/k6/ no-reference pipeline, fold k6: model.pth, metrics, predictions results/pipeline_unbias/ debiased MOS, ANOVA table, the five plots results/webapp/ the tables the study app produced tests/ run.sh + the checks above third_party/magface a gitlink with no content and no .gitmodules (empty in a clone) LICENSE, LICENSE-NOTES.md MIT and its scope ``` The virtualenv used during development (`.local/`) used to be tracked — 350 files, why a clone came down at ~178 MB. It is out of the index now and ignored; a fresh clone reproduces the environment from `requirements.txt` instead. ## License **MIT, with a scope: only for the code and text authored by André Neto.** Nine tracked files carry an institutional copyright header (`Copyright (c) 2024/2025 Institute of Systems and Robotics`) and are **not** covered by the MIT licence — the rights stay with the institution, and no authorisation from it to relicense them is recorded here. The list and the scope are in [`LICENSE-NOTES.md`](LICENSE-NOTES.md); the MIT text is in [`LICENSE`](LICENSE). The nine files: `metrics/__init__.py`, `metrics/objective/__init__.py`, `metrics/objective/full_reference/__init__.py`, `metrics/subjective/__init__.py`, `metrics/subjective/pre_processing.py`, `metrics/subjective/post_processing.py`, `metrics/subjective/compute_mos.py`, `metrics/subjective/anova.py`, `scripts/compute_subjective.py`. Data is not covered by that licence either: - The **participant data** (`app_user_user.csv`, `app_ss_session.csv`, `app_ss_test.csv`, `app_user_feedback.csv`, and the derived `results/webapp/tests.csv`) is personal data, anonymised: the identifiers are pseudonyms derived from a private salt that is **not** in this repository, the age became a bracket, and the free text was stripped of contacts. `results/webapp/tests.csv` carries the observer age as the group `anova.py` already used, so no age in years is published anywhere. What it is and how it was treated is in [`metrics/subjective/tables/DATA-SOURCES.md`](metrics/subjective/tables/DATA-SOURCES.md) and in the header of `metrics/subjective/anonymise_tables.py`. - The **London Faces** base (`london_faces_info.csv`, `london_faces_ratings.csv`) is the Face Research Lab London Set, by Lisa DeBruine & Benedict Jones (2017), University of Glasgow — under **CC BY 4.0**, reused here with the attribution written in the same `DATA-SOURCES.md`.