Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Skin: face, neck, arms, hands, legs, feet

🧪 in progress · the one tier of shadow works and the output was judged a failure; one method currently paints every location · the method name and where a person writes it: appendix G · code: appendix B

How an artist paints it

Anime skin is one hard-edged tier of shadow: the local colour fills it, and the shadow is one shape in one colour (a little darker than the local colour and toward red) with hard edges, softened with an airbrush in only a few places (the cheek, the top of the thigh). There is almost no highlight, at most a touch on the nose or a shoulder. The shape of the shadow depends on where it is:

  • The face: the shadow the fringe presses onto the forehead (its shape following the fringe’s edge), a thin shadow down one side of the nose, a small one under the lower lip, and the largest of them on the neck; the blush is a soft patch of pink sitting above the shadow; and the eyes and the mouth take no part in the banding (they have their own page).
  • The neck: a large shadow cast by the chin, hard along its upper edge (the chin’s shape) and graduating downward toward the collarbone; plus two thin shadows on the collarbone.
  • The arm: a cylinder – one shadow running along the inner side, a hard shadow pressed by the cuff, and one in the crook of the elbow.
  • The hand: a thin shadow down one side of each finger, something deeper between them, and almost nothing on the back of the hand.
  • The thigh: a cylinder’s gradient (bright outside, dark inside), with the hard shadow the skirt presses onto it mattering most, and a touch of brightness on the knee; with the legs together, a deep seam between them.
  • The calf: as the thigh, with the shadow at the back, plus one pressed by the top of a stocking or a shoe.
  • The foot: a touch of brightness on the instep, a shadow down one side of the toes, and a hard shadow pressed by the shoe.

What it looks like in the source

The luminance histogram is bimodal: one peak for the local colour and one for the shadow, with the airbrush transition between them and a dark tail below made of the lines and the mouth. The shadow’s colour is not far from the local colour, so splitting by luminance is steadier than splitting by colour; and the blush is a patch where the colour changes and the luminance does not.

Our method 🧪

The method bands only the visible pixels (in the completed image the skin under the clothing was painted as something else, and banding on that cuts out a top); subtract the eye and mouth masks (exclude), without which the darkest band is a layer of pupils, mouth and nostrils; look only at luminance in [local colour - line_drop, local colour + 10] after a sigma=1 blur (the lines belong to the line layer); find the valley between the two peaks with Otsu, and everything darker than the valley is shadow; open and close by 2 px to remove the remains of the lines and the fuzz from gradients; discard pixels more than col_tol from the band’s colour (the blush) and leave them to the residual; and vectorize into a Shape -> the <G>_Shadow subgroup (a vector Shape plus a clipped flat fill, kind shadow). The residual soft strokes (kind blend) land on the _Blend layer above the band: where the source has a gradient they blend it back in, and where the source has a hard edge the residual is too small to start a stroke and the edge stays; the hard brush stays on _Shade, below the band.

A band wins on layering, not on sharpness: the baseline’s hard brush already copies a shadow edge hard enough. What a band is worth is that the “shadow” an artist asks for becomes a named layer – a vector shape with a flat fill inside it, rather than a patch inside tens of thousands of airbrush strokes. A band with no residual loses: the lines, the mouth, the blush and the gradients all disappear. K-means (k=2, in RGB) does not work: the dark tail drags it away and the “shadow” it cuts out is the blended pixels of the outlines.

Why the output was judged a failure: there is only one band and the whole skin group is banded together, so the face, the neck and the thigh all depend on one Otsu threshold; the band’s edges are softer than the source’s (the band-edge reading is below the source’s, ch. 19); the residual and the hard brush together still amount to copying, leaving the neck and the collarbone a soft blur; and the skin group’s layer tree has 14 nodes, over the limit of 10 per group.

Layers

Skin/: Shape -> _Flat -> _Shade (the hard brush) -> _Shadow/ (a vector Shape plus a flat Paint) -> _Blend (the residual soft strokes) -> _Line.

How a person writes it in, and its knobs

"Skin": dict(method="tiers", exclude=["mask_eyes.png", "mask_mouth.png"]),
Knobsdefaultmeaning
exclude[]the mask files taking no part in the banding, from segment’s ai/: the eyes and the mouth
line_drop60band only pixels whose luminance is at least the local colour minus this (anything darker is a line)
col_tol40discard pixels further than this from the band’s colour (the blush) and leave them to the residual
residualtrueadd the residual soft strokes and the hard brush above the band

Criteria

The per-group rulers (ch. 7): the band’s edge (the gradient p90 on the band Shape’s boundary, compared with the source at the same positions – this is where a band wins or loses), interior sharpness, and 1x PSNR. A person looks at the shadow layer on its own to see whether its shape is right (does the chin’s shadow look like a chin), and the four close-ups (face, neck, hand, foot) are looked at every time.

Where it breaks

  • Banding on the completed image: whatever the model painted under the clothing gets cut out as a band.
  • Not subtracting the eyes and the mouth: the darkest band is the pupils plus the mouth plus the nostrils.
  • One threshold for the whole body: the face’s shadow and the thigh’s differ in luminance, and one Otsu valley is wrong at both ends.
  • A band with no residual: the blush and the gradients disappear. A residual with no band: back to copying.
  • Too deep a tree: 14 nodes in one group, over the limit of 10 per group (ch. 7).

What has to be decided

  • Whether the choice should be made per sub-part (Skin_Face / Skin_Arm / Skin_Leg_L and so on, each with its own threshold and its own shadows), or one method per group with knobs for the location.
  • Whether each location’s shadow is separated out of the source (Otsu) or drawn by rule (the chin’s shadow being the chin’s shape translated downward).
  • Which layer the blush belongs to, and whether thin shadows like the nose’s and the collarbone’s belong to the lines or to a band.
  • How to get the tree back under 10 nodes per group (merge _Shade and _Blend? drop the band’s Paint layer?).

On origin

Ch. 18, “The layered route”: the skin group’s stroke count, the band’s pixel count and threshold, the band edges, and interior sharpness; plus the three skin variants in “Three part experiments”.