@thi.ng/pixel-analysis 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/README.md +24 -2
- package/hues.d.ts +5 -4
- package/hues.js +2 -3
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2025-
|
|
3
|
+
- **Last updated**: 2025-06-09T17:24:08Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -11,6 +11,15 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
11
11
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
12
12
|
and/or version bumps of transitive dependencies.
|
|
13
13
|
|
|
14
|
+
## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/pixel-analysis@0.2.0) (2025-06-02)
|
|
15
|
+
|
|
16
|
+
#### 🚀 Features
|
|
17
|
+
|
|
18
|
+
- update hue range fns ([27d43aa](https://github.com/thi-ng/umbrella/commit/27d43aa))
|
|
19
|
+
- simplify/optimize warmIntensityHsv()
|
|
20
|
+
- update args to accept int buffers
|
|
21
|
+
- add tests
|
|
22
|
+
|
|
14
23
|
## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/pixel-analysis@0.1.0) (2025-05-28)
|
|
15
24
|
|
|
16
25
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 209 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
> GitHub](https://github.com/sponsors/postspectacular). Thank you! ❤️
|
|
16
16
|
|
|
17
17
|
- [About](#about)
|
|
18
|
+
- [Color analysis](#color-analysis)
|
|
18
19
|
- [Status](#status)
|
|
19
20
|
- [Installation](#installation)
|
|
20
21
|
- [Dependencies](#dependencies)
|
|
@@ -26,6 +27,27 @@
|
|
|
26
27
|
|
|
27
28
|
Image color & feature analysis utilities. This is a support package for [@thi.ng/pixel](https://github.com/thi-ng/umbrella/tree/develop/packages/pixel).
|
|
28
29
|
|
|
30
|
+
### Color analysis
|
|
31
|
+
|
|
32
|
+
- Dominant colors in different color modes/formats:
|
|
33
|
+
- CSS
|
|
34
|
+
- sRGB
|
|
35
|
+
- HSV
|
|
36
|
+
- Oklch (perceptual)
|
|
37
|
+
- Normalized areas of dominant color clusters
|
|
38
|
+
- Min/max HSV hue range of dominant colors
|
|
39
|
+
- Min/max HSV saturation range of dominant colors
|
|
40
|
+
- Min/max Oklch chroma range of dominant colors
|
|
41
|
+
- Min/max luminance range of dominant colors (obtained from SRGB)
|
|
42
|
+
- Min/max luminance range of entire grayscale image (obtained from SRGB)
|
|
43
|
+
- Normalized warmth, i.e. the area-weighted intensity of "warm" colors in the image
|
|
44
|
+
- Luminance contrast of dominant colors
|
|
45
|
+
- Luminance contrast of entire grayscale image
|
|
46
|
+
- Max. normalized WCAG color contrast of dominant colors
|
|
47
|
+
- Average luminance of dominant colors, weighted by area
|
|
48
|
+
- Average HSV saturation of dominant colors, weighted by area
|
|
49
|
+
- Average Oklch chroma of dominant colors, weighted by area
|
|
50
|
+
|
|
29
51
|
## Status
|
|
30
52
|
|
|
31
53
|
**BETA** - possibly breaking changes forthcoming
|
|
@@ -58,7 +80,7 @@ For Node.js REPL:
|
|
|
58
80
|
const pa = await import("@thi.ng/pixel-analysis");
|
|
59
81
|
```
|
|
60
82
|
|
|
61
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 1.
|
|
83
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 1.28 KB
|
|
62
84
|
|
|
63
85
|
## Dependencies
|
|
64
86
|
|
package/hues.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FloatBuffer } from "@thi.ng/pixel/float";
|
|
2
|
+
import type { IntBuffer } from "@thi.ng/pixel/int";
|
|
2
3
|
/**
|
|
3
4
|
* Iterator yielding HSV pixel values/colors matching given hue range and
|
|
4
5
|
* minimum saturation.
|
|
@@ -8,7 +9,7 @@ import type { FloatBuffer } from "@thi.ng/pixel/float";
|
|
|
8
9
|
* @param maxHue
|
|
9
10
|
* @param minSat
|
|
10
11
|
*/
|
|
11
|
-
export declare function selectHueRangeHsv(img: FloatBuffer, minHue: number, maxHue: number, minSat: number): Generator<Float32Array<ArrayBufferLike>, void, unknown>;
|
|
12
|
+
export declare function selectHueRangeHsv(img: IntBuffer | FloatBuffer, minHue: number, maxHue: number, minSat: number): Generator<Uint8Array<ArrayBufferLike> | Float32Array<ArrayBufferLike> | Uint8ClampedArray<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>, void, unknown>;
|
|
12
13
|
/**
|
|
13
14
|
* Similar to {@link selectHueRangeHsv}, but only returns a count of HSV pixel
|
|
14
15
|
* values/colors matching given hue range and minimum saturation (all
|
|
@@ -19,7 +20,7 @@ export declare function selectHueRangeHsv(img: FloatBuffer, minHue: number, maxH
|
|
|
19
20
|
* @param maxHue
|
|
20
21
|
* @param minSat
|
|
21
22
|
*/
|
|
22
|
-
export declare const countHueRangeHsv: (img: FloatBuffer, minHue: number, maxHue: number, minSat: number) => number;
|
|
23
|
+
export declare const countHueRangeHsv: (img: IntBuffer | FloatBuffer, minHue: number, maxHue: number, minSat: number) => number;
|
|
23
24
|
/**
|
|
24
25
|
* Takes a list of hue ranges and computes the area-weighted mean intensity of
|
|
25
26
|
* matching pixels in the given image. Also see {@link warmIntensityHsv}.
|
|
@@ -31,7 +32,7 @@ export declare const countHueRangeHsv: (img: FloatBuffer, minHue: number, maxHue
|
|
|
31
32
|
* @param hues
|
|
32
33
|
* @param minSat
|
|
33
34
|
*/
|
|
34
|
-
export declare const hueRangeIntensityHsv: (img: FloatBuffer, hues: [number, number][], minSat?: number) => number;
|
|
35
|
+
export declare const hueRangeIntensityHsv: (img: IntBuffer | FloatBuffer, hues: [number, number][], minSat?: number) => number;
|
|
35
36
|
/**
|
|
36
37
|
* Syntax sugar for {@link hueRangeIntensityHsv} to compute the area-weighted mean
|
|
37
38
|
* intensity of pixels in the yellow/orange/red hue ranges.
|
|
@@ -39,5 +40,5 @@ export declare const hueRangeIntensityHsv: (img: FloatBuffer, hues: [number, num
|
|
|
39
40
|
* @param img
|
|
40
41
|
* @param minSat
|
|
41
42
|
*/
|
|
42
|
-
export declare const warmIntensityHsv: (img: FloatBuffer, minSat?: number) => number;
|
|
43
|
+
export declare const warmIntensityHsv: (img: IntBuffer | FloatBuffer, minSat?: number) => number;
|
|
43
44
|
//# sourceMappingURL=hues.d.ts.map
|
package/hues.js
CHANGED
|
@@ -43,9 +43,8 @@ const hueRangeIntensityHsv = (img, hues, minSat = 0.2) => {
|
|
|
43
43
|
const warmIntensityHsv = (img, minSat) => hueRangeIntensityHsv(
|
|
44
44
|
img,
|
|
45
45
|
[
|
|
46
|
-
[
|
|
47
|
-
|
|
48
|
-
[345 / 360, 15 / 360]
|
|
46
|
+
[345 / 360, 55 / 360]
|
|
47
|
+
// red, orange, yellow
|
|
49
48
|
],
|
|
50
49
|
minSat
|
|
51
50
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/pixel-analysis",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Image color & feature analysis utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@thi.ng/color": "^5.7.
|
|
43
|
-
"@thi.ng/compare": "^2.4.
|
|
44
|
-
"@thi.ng/math": "^5.11.
|
|
45
|
-
"@thi.ng/pixel": "^7.5.
|
|
46
|
-
"@thi.ng/pixel-convolve": "^1.1.
|
|
47
|
-
"@thi.ng/pixel-dominant-colors": "^1.1.
|
|
48
|
-
"@thi.ng/transducers": "^9.
|
|
49
|
-
"@thi.ng/vectors": "^8.
|
|
42
|
+
"@thi.ng/color": "^5.7.39",
|
|
43
|
+
"@thi.ng/compare": "^2.4.21",
|
|
44
|
+
"@thi.ng/math": "^5.11.29",
|
|
45
|
+
"@thi.ng/pixel": "^7.5.1",
|
|
46
|
+
"@thi.ng/pixel-convolve": "^1.1.1",
|
|
47
|
+
"@thi.ng/pixel-dominant-colors": "^1.1.47",
|
|
48
|
+
"@thi.ng/transducers": "^9.4.0",
|
|
49
|
+
"@thi.ng/vectors": "^8.3.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"esbuild": "^0.25.5",
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
"status": "beta",
|
|
107
107
|
"year": 2024
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "93cdcd8db4d4669561a7f0ebc47697bdbfd04214\n"
|
|
110
110
|
}
|