@thi.ng/pixel-analysis 0.1.0 → 0.2.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-05-28T12:02:40Z
3
+ - **Last updated**: 2025-06-02T21:17:03Z
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
@@ -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.29 KB
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<Float32Array<ArrayBufferLike> | Uint8Array<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
- [15 / 360, 35 / 360],
47
- [35 / 360, 55 / 360],
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.0",
3
+ "version": "0.2.0",
4
4
  "description": "Image color & feature analysis utilities",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -106,5 +106,5 @@
106
106
  "status": "beta",
107
107
  "year": 2024
108
108
  },
109
- "gitHead": "61c3833b7ef7d044621454b5ea4af885d39f065e\n"
109
+ "gitHead": "1a4408bfd547a11330b80c2a0b37f85e2c65ab17\n"
110
110
  }