Library / SDK
andrewekhalel/sewar avatar
andrewekhalel/sewar

sewar: sixteen image quality metrics behind one Python import

All image quality metrics you need in one package.

612 stars71 forksPythonMIT

At a glance

What is it?
Sewar bundles the reference and no-reference quality metrics that super-resolution and pansharpening papers use, behind a uniform numpy array convention and a sewar command line entry point. The convenience is real, but the packaging metadata has drifted behind the dependency floors.
Who is it for?
Adopt sewar when you need several standard quality metrics applied to full-reference image pairs and want one array convention plus a command line path, and skip it when your images need no-reference scoring from the shell, since that is still an open item in the README. Verify first by checking the installed version against the 0.4.9 declared in setup.py, and by confirming that the numpy, scipy and Pillow floors in requirements.txt suit your interpreter.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 3 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 24, 2026, and from our analysis. They are not legal advice.

Editorial analysis

One import path for the metrics super-resolution papers keep reimplementing

Sewar is a Python package for image quality assessment, described in the README as all image quality metrics you need in one package. Its audience is fairly narrow and easy to name: people working on super-resolution, pansharpening and image fusion who need to report PSNR, SSIM, ERGAS or a handful of similar numbers and would rather not transcribe formulas from papers into each new script. The README lists sixteen implemented metrics, from Mean Squared Error and Root Mean Squared Error through Peak Signal-to-Noise Ratio, Structural Similarity Index, Universal Quality Image Index, Multi-scale SSIM, ERGAS, Spatial Correlation Coefficient, Relative Average Spectral Error, Spectral Angle Mapper, Spectral Distortion Index, Quality with No Reference, Visual Information Fidelity, PSNR-B and the Hypercomplex Image Quality Index. Each entry links to the paper that defines it, so the metrics are traceable rather than folklore. The convenience on offer is uniform plumbing around those definitions: one input convention, one package, and a way to run a metric from a shell.

Every metric expects numpy arrays in H x W x C

The mechanism is deliberately plain. Metric functions take two arrays for the reference pair, and the README states that all metric functions expect numpy arrays in H x W x C format, meaning height by width by channels. The functions are grouped by module, and the example imports from sewar.full_ref, which is where the full-reference metrics live, while the no-reference family, including Quality with No Reference and the spectral distortion indexes, sits apart. The README gives this example for UQI.

python
>>> import numpy as np
>>> from PIL import Image
>>> from sewar.full_ref import uqi
>>> img1 = np.asarray(Image.open("image1.tif"))
>>> img2 = np.asarray(Image.open("image2.tif"))
>>> uqi(img1, img2)
0.8847521481522062

Loading through PIL and converting with np.asarray is what makes the convention reachable from ordinary image files, and the returned value is a plain float. Note the shape rule: height first, width second, channels last. Multi-channel and hyperspectral inputs are part of the design, which is why the hypercomplex index Q2n is in the list at all.

The install is one pip line, but the dependency floors are strict

Installation is stated as just as simple as a single pip command.

bash
pip install sewar

Behind that command sit three dependencies. The setup.py file declares them as install_requires with numpy, scipy and Pillow, and the requirements file in the repository pins lower bounds rather than exact versions.

code
numpy>=2.0.0
scipy>=1.11.1
Pillow>=10.0.1

Those floors are worth a second look. A numpy floor at 2.0.0 is a recent baseline, and it rules out the older interpreters that the packaging metadata still advertises, since setup.py lists classifiers for Python 2.6, 2.7, 3.1, 3.2, 3.3, 3.4, 3.5 and 3.6 alongside Python 3. The classifier list and the dependency floors disagree about which interpreters are realistic, and the dependency floors are the part that actually resolves during installation. Test your environment against the floors before planning around the advertised Python versions.

The sewar command line wraps the same functions

A console script is registered in setup.py under the name sewar, pointing at sewar.command_line:main, so installing the package also installs a command called sewar. The documented syntax is a metric name, a ground truth path and a processed path, with any extra parameters after that.

shell
sewar [metric] [GT path] [P path] (any extra parameters)

A worked example runs SSIM over a ground truth and a deformed image with a window size argument, and the printed output carries both the metric name and the value.

shell
foo@bar:~$ sewar ssim images/ground_truth.tif images/deformed.tif -ws 13
ssim : 0.8947009811410856

The list of metrics the command line accepts is given explicitly: mse, rmse, psnr, rmse_sw, uqi, ssim, ergas, scc, rase, sam, msssim, vifp, psnrb and q2n. Fourteen names for sixteen documented metrics. The two spectral distortion indexes and the no-reference quality score are absent from that list, and the reason is stated elsewhere in the README, which carries an open task to add command-line support for no-reference metrics.

Tests run through pytest with coverage, and codecov tracks them

The repository carries the usual scaffolding for a small Python library. The top level holds setup.py, requirements.txt, MANIFEST.in, a LICENSE file, a docs directory and the sewar package itself, and a .github directory holds the workflow that drives the build badge shown in the README. The README documents how to run the test suite with coverage.

bash
pip install pytest pytest-cov
pytest --cov=sewar

The extra test requirements in setup.py are pytest, pytest-cov and Pillow, and the README links a codecov badge, so coverage results are published for each build rather than only printed locally. For a metrics library that matters more than usual, because a metric that silently returns the wrong number is worse than a metric that fails loudly. Tests can confirm that the functions run, but the README does not describe a validation set with known reference scores, so the correctness of any individual metric against its source paper has to be checked by reading the implementation or by comparing against a known result.

Where sewar is the wrong tool

There are several honest reasons to look elsewhere. The first is no-reference scoring from a shell, which the README still lists as an open task, so a pipeline step that must be reproducible as a command cannot use it yet. The second is that the package is not released in any formal sense: the repository has no GitHub releases, and the only version signal is the version string 0.4.9 in setup.py, while the packaging metadata also carries the classifier Development Status :: 2 - Pre-Alpha. A project marked pre-alpha while shipping a specific dependency floor set gives you mixed signals about how much of the numeric output you should treat as settled. Third, the metrics assume paired inputs for the reference family, so any workflow where only one image exists needs the no-reference functions, which are reachable from Python but not from the command line.

A hand written numpy routine versus a maintained package

The alternative is the one many research scripts already use: implement the metric yourself. A PSNR or SSIM function is short, and writing it means you control the window size, the data range and the border handling, which is sometimes exactly what a paper requires. The cost is that each implementation is a fresh chance to get the formula or the boundary handling wrong, and the same metric written twice can report different numbers for the same pair of images, which is worse than either number being wrong on its own. Sewar takes the opposite position. One package, one array convention, one command, and the definitions linked to their papers in the README, which makes a table of results comparable across projects. The trade-off is that the flexibility of a local script is gone, since a metric with unusual parameters has to be accepted as the package implements it or worked around in Python rather than edited.

Licence, release posture and upkeep

Sewar is published under the MIT licence, which the setup.py classifiers confirm and which keeps the code usable inside closed research codebases without copyleft obligations on the surrounding work. The last push to the repository was on 2026-10-17, so the work is current rather than abandoned, and the README points to hosted documentation at http://sewar.readthedocs.io/ alongside badges for downloads, the build workflow and codecov. There is no homepage listed beyond the repository URL in setup.py, and no changelog or release history in the repository, so the practical upgrade signal is the PyPI version rather than a dated note. The README also credits two contributors, @sachinpuranik99 and @sunwj, which is a small surface for a package whose value rests on getting numeric details right.

Editorial conclusion

Adopt sewar when you need several standard quality metrics applied to full-reference image pairs and want one array convention plus a command line path, and skip it when your images need no-reference scoring from the shell, since that is still an open item in the README. Verify first by checking the installed version against the 0.4.9 declared in setup.py, and by confirming that the numpy, scipy and Pillow floors in requirements.txt suit your interpreter.

Frequently asked questions

How do I install sewar and what does it pull in?

The README gives a single install command, pip install sewar. The package depends on numpy, scipy and Pillow, and the requirements file sets lower bounds of numpy>=2.0.0, scipy>=1.11.1 and Pillow>=10.0.1.

What input format do the sewar metric functions expect?

All metric functions expect numpy arrays in H x W x C format, meaning height by width by channels. The README example loads files with PIL and converts them with np.asarray before passing them to a metric function.

Can I run no-reference metrics from the sewar command line?

Not yet. The README lists adding command-line support for no-reference metrics as an open task, and the documented list of available metrics does not include the spectral distortion indexes or the no-reference quality score.

Official sources

  1. andrewekhalel/sewar on GitHub
  2. Issues
  3. License: MIT
  4. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/andrewekhalel-sewar.svg)](https://hysenlabs.com/projects/andrewekhalel-sewar)

Was this useful?