# How style measurements work

A [style check](/docs/style-checks) gives each delivered image eight readings and compares them with the readings of the style's own references and samples. This page describes how each reading is worked out, so that an artist or a generative tool can tell what moved a reading out of range and how to bring it back. All of this is plain arithmetic on pixels. No AI is involved, so the same file always gives the same numbers.

The best way to fit a style is still to work from its words and references. The readings show where an image drifted, but they can't tell you what makes it good, and a style check is a warning a reviewer can accept anyway.

## Before anything is measured

- **Scaled down.** The image is averaged down in square blocks until its long side is at most 256 pixels. A 2048 × 1024 image is averaged in 8 × 8 blocks to 256 × 128. Images that are already smaller are measured as they are, never scaled up. All the readings below therefore describe the image at about 256 pixels, as if you were looking at a thumbnail.
- **Transparent pixels left out.** A pixel counts only when its alpha is at least 128 (half opaque), and a block counts only when at least half of its pixels do. A cut-out character on a transparent background is measured on the character alone. A solid background, even plain white, is part of the image and is measured with it.
- **Brightness of a pixel.** Several readings use each pixel's luminance, `0.2126 R + 0.7152 G + 0.0722 B`, with each channel from 0 to 1 as stored in the file. Green counts for most of it and blue for very little, so a pure blue `#0000FF` has a luminance of only 0.07, while a pure yellow `#FFFF00` has 0.93.
- **Neighbours.** Edges, flat fills and texture compare each pixel with the eight around it. A transparent neighbour is treated as the same as the pixel itself, so the border of a cut-out isn't counted as an edge. Pixels on the outermost row and column aren't counted.

## The eight readings

| Reading | Range | In one line |
| --- | --- | --- |
| Ink coverage | 0 to 1 | Share of pixels darker than luminance 0.18 |
| Edge density | 0 to 1 | Share of pixels on a sharp change in brightness |
| Flat vs gradient | 0 to 1 | Share of pixels in a perfectly even fill |
| Colour count | 0 and up | Colours that cover at least 0.2% of the image |
| Saturation | 0 to 1 | Average vividness |
| Brightness | 0 to 1 | Average luminance |
| Warmth | 0 to 1 | Average lean to red (above 0.5) or blue (below 0.5) |
| Texture fingerprint | 0 to 1 | How far the image's small-scale patterns sit from the references' average |

### Ink coverage

The share of measured pixels whose luminance is below **0.18**, which is about `#2E2E2E` in grey. It is meant to pick up inked contours, solid blacks and dense crosshatching.

- Because the image is scaled down first, a line counts as ink only when it is still dark after averaging. A one-pixel black line on a 2048-pixel image is averaged with seven lighter pixels and usually no longer counts. Heavier lines and solid black areas raise ink coverage. Thin, delicate lines barely move it.
- Dark colours count as well as black. A deep navy, a dark purple or a saturated blue is below 0.18 and counts as ink, and so is a dark red such as `#800000` (luminance 0.11). Deep shadows painted in colour raise the reading.
- **Too low:** thicken contours, fill shadows with solid black or near-black, darken the darkest values. **Too high:** thin the lines, lift shadows from black to a dark colour above 0.18, or use fewer solid black areas.

### Edge density

The share of pixels sitting on a sharp change in brightness. At each pixel, a [Sobel filter](https://en.wikipedia.org/wiki/Sobel_operator) on luminance gives the slope, and the pixel counts as an edge when the slope's strength is above **0.4**. In practice that is a step of about a tenth of the full brightness range (around 26 grey levels out of 255) from one side of the pixel to the other, at the 256-pixel scale.

- Hard outlines, hatching, crisp cel shading and fine detail raise it. Soft blending, blur, atmospheric haze and large plain areas lower it.
- Colour changes only count when their brightness differs. A red shape next to a green shape of the same brightness is not an edge.
- **Too low:** add or darken outlines, sharpen transitions between shadow and light, add detail. **Too high:** soften transitions, drop interior lines, simplify busy detail, or let large areas stay plain.

### Flat vs gradient

The share of pixels that sit in a perfectly even fill. The image is halved again, to about 128 pixels on its long side, so JPEG speckle averages out, and only spots where all four pixels being averaged are opaque are kept. A pixel is flat when its Sobel slope there is below **0.012**. That is very strict: a gradient that changes by more than about a fifth of the brightness range across the whole width of the image is already not flat, and so is any edge or line.

- Flat colour fills, cel shading and vector-style art raise it. Gradients, painted light, soft shading, paper texture, grain, noise and dithering all lower it, however gentle they look.
- **Too low:** fill areas with a single colour, replace soft shading with one or two hard-edged shadow tones, remove grain and texture overlays. **Too high:** add gradients or painted light to large fills, or add the kind of surface texture the references have.

### Colour count

How many colours carry the image. Each channel is cut into 16 levels, which gives 4,096 colour bins, and every measured pixel falls into one. The reading counts the bins that hold at least **0.2%** of the measured pixels (1 in 500). Anti-aliasing, speckle and small accents fall below that and aren't counted.

- Shades less than about 16 grey levels apart in every channel usually land in the same bin, so tiny variations don't add colours. Gradients that run across many shades, painted light and textured surfaces each add many bins.
- **Too high:** use a smaller palette, replace gradients with a few flat steps, or posterize. **Too low:** add the shading steps or accent colours the references use, over large enough areas to count.

### Saturation

The average vividness of the measured pixels, using the HSV definition: `(max − min) / max` of the pixel's red, green and blue. Grey, black and white are 0; a pure colour is 1.

- Because it divides by the brightest channel, dark colours count fully. A nearly black pixel with a slight colour cast, such as `#100800`, is as saturated as a bright orange. Shadows tinted with colour therefore raise saturation more than you'd expect, and neutral grey or black shadows lower it.
- **Too high:** desaturate, use greyer or more neutral shadows, or mix complements into the colours. **Too low:** push the main colours toward pure hues, and tint shadows rather than greying them.

### Brightness

The average luminance of the measured pixels, using the luminance formula above. Green carries most of it and blue very little, so a blue-heavy image reads darker than it looks next to a yellow or green one of the same value.

- A background counts. The same character reads much brighter on white than on a transparent background.
- **Too low:** lift midtones and shadows, use a lighter background, or use less black. **Too high:** deepen shadows and midtones, or use a darker background. A levels or curves adjustment moves this reading the most predictably.

### Warmth

The average of `(R − B) / 2 + 0.5` over the measured pixels. 0.5 is neutral; pure red or yellow reads 1, pure blue reads 0. Green doesn't count at all, so a green image reads neutral.

- **Too low (too cool):** shift the colour balance toward red and yellow, use warmer light, or warm the shadows with browns and reds. **Too high (too warm):** shift toward blue, use cooler light or bluer shadows.

### Texture fingerprint

The only reading that isn't a single number. It describes how the image is drawn at a small scale, so it separates inked hatching from brushwork, or clean cel shading from a noisy painted surface, even when the colours match. It is made of 18 values in two halves.

**Local patterns (10 values).** For each pixel, the eight neighbours are compared with it, and a neighbour is marked when it is brighter by at least **0.02** (about 5 grey levels). Going round the ring of neighbours, if the marks form one unbroken run, the pixel is filed by how many neighbours are marked, from 0 to 8. Otherwise, when the marks are scattered around the ring, it goes into a tenth bin for broken patterns. Each bin's share of the pixels is one value.

- Pixels in an even fill, or on the bright side of an edge, have no brighter neighbours and land in bin 0.
- Pixels on the edge of a shape have about half their neighbours brighter and land in the middle bins.
- Pixels on a thin dark line, in hatching, in grain or in busy brushwork have brighter neighbours on both sides, and land in the tenth bin. A heavily hatched image has a large share there; a clean flat image has a small one.

**Stroke directions (8 values).** For each pixel with any slope at all (Sobel strength above 0.02), the slope's direction is placed in one of eight 22.5° slices of a half turn, weighted by how strong the slope is. An edge and its opposite count as the same direction. Each slice's share of the total is one value. Hatching laid at one angle piles weight into one or two slices; loose brushwork spreads it evenly; architecture and pixel art pile it into horizontal and vertical.

**The distance.** The fingerprint is compared with the average fingerprint of the style's references. The distance is half the summed difference of the patterns, and half the summed difference of the directions, averaged. 0 is the same texture; 1 is nothing in common. Review shows the image's distance against how far the style allows, which is how far its most unusual reference sits from that average, times 1.25, and never less than 0.05.

- **Too far away:** look closely at the references at thumbnail size, and match how they're drawn. Use the same tool and stroke (hatching or brush, pen or pencil, clean fills or textured ones), the same density of lines, and the same main stroke angles. Grain, noise and texture overlays that the references don't have push the fingerprint away, and so does a clean, smooth finish when the references are hatched.
- Changing colour, brightness or saturation alone barely moves the fingerprint. It has to change in how the image is drawn.

## The style's range

For each of the first seven readings, the style's range is the lowest to the highest value among the references and samples it is compared with, widened on each side by 15% of that span, or by a minimum amount when the span is small:

| Reading | Least widening each side |
| --- | --- |
| Ink coverage | 0.02 |
| Edge density | 0.02 |
| Flat vs gradient | 0.04 |
| Colour count | 4 colours |
| Saturation | 0.04 |
| Brightness | 0.04 |
| Warmth | 0.02 |

The range never goes below 0, and never above 1 except for colour count. When the image has a `role` tag, such as `role=portrait`, and at least three references share it, only those references and the style's sample images set the range. See [Style checks](/docs/style-checks#how-it-compares).

An image is **outside the style** when two or more of the eight readings are out of range. One reading out of range is shown, but still matches. The summary line names the three readings furthest out, measured in widths of their range, so the first one named is usually the one to fix first.

## Bring an image back into the style

- **See the readings.** Review shows each reading with its value, the range and a bar. A project member can also measure a delivery that's waiting for review with `agh style compare <asset> --pending`, or `compare_styles` with `file: "pending"`. A revision request after a style check usually quotes the summary line.
- **Fix the furthest reading first.** Readings pull on each other, so after one change, measure again rather than fixing all of them at once. The most common links: darkening lowers brightness and raises ink coverage; adding outlines raises edge density and ink, and lowers flat; adding gradients, grain or texture lowers flat and raises colour count and edge density; posterizing does the opposite; warming the colours often raises saturation.
- **Match the presentation, not just the art.** Deliver on the same kind of background as the references. A transparent cut-out compared with references that are cut-outs, a scene with scenes. A white or coloured background changes brightness, flat, colour count, warmth and often ink. Add a matching `role` tag when the style has references for that role, so a portrait isn't compared with backgrounds.
- **Mind the scale.** Everything is measured at about 256 pixels. Details smaller than one pixel at that size, such as hairline lines on a 4K canvas, average away. Judge your image as a thumbnail next to the references' thumbnails.
- **Tone and colour are easy to adjust; texture isn't.** Brightness, saturation and warmth move predictably with levels, curves, hue/saturation and colour balance, and colour count with posterizing. Edge density and flat vs gradient move with sharpening, blurring, grain and how you shade. The texture fingerprint only moves when the drawing technique changes.
- **When the style itself looks wrong.** A style with only three similar references has narrow ranges. If good work keeps coming out outside, the fix is more varied references or samples on the style, which an admin can add under **Style guides**, not bending each image to fit.

## Nudge an image toward the style

On Pro, Team and Enterprise, Asset Goes Here can make the tone and colour fixes for you. When the style check on a delivery waiting for review says it's outside, the card offers **Nudge toward style…** to the fulfiller who delivered it and to reviewers (admins and developers). Agents use `nudge_to_style`.

- **What it adjusts.** Brightness with levels (gamma, and the white point when darkening), ink coverage with a curve on the dark half of the tones, saturation with a saturation scale, warmth with a red/blue colour balance, and colour count by posterizing. It can also sharpen to add edges and add a fine grain to break up flat fills. It's plain image processing, with no AI, and the same file always gives the same result.
- **What it can't.** Posterizing only lowers the colour count, sharpening only raises edge density, and grain only lowers flat vs gradient: the other way means redrawing or repainting. The texture fingerprint is never adjusted, because it records the mark-making itself. That stays with the artist.
- **How it works.** It adjusts one ticked reading at a time, just inside its range, measures the whole image again, and goes round again, up to four passes, since the readings pull on each other. A reading that was in range and gets pushed out is brought back too. Each adjustment has a limit, so it stops before it clips highlights, crushes line work or tints the whole picture, and says which reading still misses and why.
- **Preview first.** The dialog shows the delivered image beside the nudged preview, every reading before and after against its range, and a tick box for each reading it can move. The flagged ones start ticked; untick one to leave it alone. Nothing changes until you choose **Use nudged image**.
- **Nothing is lost.** The nudged copy replaces the delivery with the same provenance and made-by, and the delivered original moves to the asset's earlier attempts. **Undo** puts it back while the delivery waits for review. Once accepted, the provenance file lists what was done, as `nudged: "toward <style> v<n>: levels, gamma 1.26; …"`.

On Free and Supporter, the style check card explains nudging and links here, with an upgrade.
