@thi.ng/pixel-analysis
Version:
Image color & feature analysis utilities
126 lines (93 loc) • 4.42 kB
Markdown
<!-- This file is generated - DO NOT EDIT! -->
<!-- Please see: https://github.com/thi-ng/umbrella/blob/develop/CONTRIBUTING.md#changes-to-readme-files -->
# 
[](https://www.npmjs.com/package/@thi.ng/pixel-analysis)

[](https://mastodon.thi.ng/@toxi)
> [!NOTE]
> This is one of 210 standalone projects, maintained as part
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
> and anti-framework.
>
> 🚀 Please help me to work full-time on these projects by [sponsoring me on
> GitHub](https://github.com/sponsors/postspectacular). Thank you! ❤️
- [About](#about)
- [Color analysis](#color-analysis)
- [Status](#status)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [API](#api)
- [Authors](#authors)
- [License](#license)
## About
Image color & feature analysis utilities. This is a support package for [@thi.ng/pixel](https://github.com/thi-ng/umbrella/tree/develop/packages/pixel).
### Color analysis
- Dominant colors in different color modes/formats:
- CSS (hex)
- sRGB
- HSV
- Oklch (perceptual)
- Normalized areas of dominant color clusters
- Min/max HSV hue range of dominant colors (considering angular wrap-around)
- Min/max HSV saturation range of dominant colors
- Min/max luminance range of dominant colors (obtained from SRGB)
- Min/max luminance range of entire grayscale image (obtained from SRGB)
- Average values for hue (circular mean), saturation, luminance
- Area-weighted average saturation of dominant colors
- Area-weighted average luminance of dominant colors
- Standard deviation for hue, saturation, luminance
- Normalized color temperature, incl. area-weighted indicator of "cold" vs
"warm" hues present
- Luminance contrast of dominant colors
- Luminance contrast of entire grayscale image
- Max. normalized WCAG color contrast of dominant colors
## Status
**BETA** - possibly breaking changes forthcoming
[Search or submit any issues for this package](https://github.com/thi-ng/umbrella/issues?q=%5Bpixel-analysis%5D+in%3Atitle)
## Installation
```bash
yarn add @thi.ng/pixel-analysis
```
ESM import:
```ts
import * as pa from "@thi.ng/pixel-analysis";
```
Browser ESM import:
```html
<script type="module" src="https://esm.run/@thi.ng/pixel-analysis"></script>
```
[JSDelivr documentation](https://www.jsdelivr.com/)
For Node.js REPL:
```js
const pa = await import("@thi.ng/pixel-analysis");
```
Package sizes (brotli'd, pre-treeshake): ESM: 1.87 KB
## Dependencies
- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
- [@thi.ng/arrays](https://github.com/thi-ng/umbrella/tree/develop/packages/arrays)
- [@thi.ng/color](https://github.com/thi-ng/umbrella/tree/develop/packages/color)
- [@thi.ng/compare](https://github.com/thi-ng/umbrella/tree/develop/packages/compare)
- [@thi.ng/math](https://github.com/thi-ng/umbrella/tree/develop/packages/math)
- [@thi.ng/metrics](https://github.com/thi-ng/umbrella/tree/develop/packages/metrics)
- [@thi.ng/pixel](https://github.com/thi-ng/umbrella/tree/develop/packages/pixel)
- [@thi.ng/pixel-convolve](https://github.com/thi-ng/umbrella/tree/develop/packages/pixel-convolve)
- [@thi.ng/pixel-dominant-colors](https://github.com/thi-ng/umbrella/tree/develop/packages/pixel-dominant-colors)
- [@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers)
- [@thi.ng/vectors](https://github.com/thi-ng/umbrella/tree/develop/packages/vectors)
Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
## API
[Generated API docs](https://docs.thi.ng/umbrella/pixel-analysis/)
TODO
## Authors
- [Karsten Schmidt](https://thi.ng)
If this project contributes to an academic publication, please cite it as:
```bibtex
@misc{thing-pixel-analysis,
title = "@thi.ng/pixel-analysis",
author = "Karsten Schmidt",
note = "https://thi.ng/pixel-analysis",
year = 2024
}
```
## License
© 2024 - 2025 Karsten Schmidt // Apache License 2.0