Line art needs the opposite treatment of a photograph. A photo model sees a flat fill as missing detail and fills it in. Here is what to do instead — and what the measurement says actually goes wrong.
Photo models are trained on grain, pores and texture. Feed them a cel-shaded frame and they decide the flat colour is impoverished, so they add shading that the artist never drew and soften hard strokes into gradients. The result is a blobby frame that reads as "AI processed" at a glance.
The fix is not a stronger setting. It is a different model class, trained on flat fills and hard edges, plus a lighter hand overall.
| Setting | On anime |
|---|---|
| Texture or grain preservation | Off. It adds speckle to flat colour |
| Aggressive denoise | Only for block artifacts. Full-frame denoise blotches fills |
| Face restoration | Usually too photographic, over-defines anime eyes |
| Sharpening after upscale | Light only. It amplifies the noise in the fills |
Block boundaries land on hard edges, which is the worst place for them. Enlarge without removing the grid and the strokes thicken with the artifact baked in.
The advice above said 2x per axis at most, because past that "line weights go uneven". That is a testable claim, so I tested it. The short version: the claim is wrong about width, and the real defect is somewhere nobody mentions — sub-pixel phase.
A 400×400 cel frame, flat fill at 0.92 luma, ink at 0.08, four vertical strokes of exactly 1, 2, 3 and 4 px. The frame is rendered at 8× and box-downsampled, so a 1 px stroke can start at any sub-pixel position instead of being snapped to the grid. That last part matters more than anything else here.
Instead of comparing pixels, the measurement integrates ink: for each stroke, sum (fill − pixel) across the stroke and divide by the fill-to-ink contrast. That gives coverage in source pixels, which is comparable across kernels and scale factors without a reference image to align.
Each stroke is measured after resampling at 2× and 4×. Error is the measured ink minus the true width, as a percentage of the true width.
| Kernel | 1 px | 2 px | 3 px | 4 px | at |
|---|---|---|---|---|---|
| bilinear | −0,09% | −0,33% | −0,09% | −0,21% | 2× |
| bicubic | −0,56% | −0,09% | −0,25% | −0,09% | 2× |
| lanczos | +0,37% | −3,36% | −0,09% | −0,21% | 2× |
| bilinear | −0,09% | −0,09% | −0,09% | −0,09% | 4× |
| bicubic | −0,09% | −0,56% | −0,09% | −0,09% | 4× |
| lanczos | −0,33% | −2,54% | −0,09% | −0,21% | 4× |
Every error except one is under 0.6%, and the numbers do not grow with the scale factor — if anything lanczos tightens from −3.35% at 2× to −2.55% at 4×. Stroke width is not what breaks. The one real outlier is lanczos on a 2 px stroke (−3.35%), the exact width where the negative lobes of the kernel land on both flanks at once; bilinear at the same width is off by a third of one percent.
So "past 2× the line weights go uneven" is refuted as stated. If a stroke comes out the wrong weight at 4×, the cause is upstream, not the scale factor.
Here is where the damage actually lives. Take eight copies of the same 1 px stroke, each offset by 1/8 px. In the source they are identical: eight 1 px lines, same ink. Render them natively at 2× and all eight measure 99.9% peak contrast. Upscale the 1× source at 2× and they do not agree at all:
| Phase (px) | bilinear | bicubic | lanczos | native 2× |
|---|---|---|---|---|
| 0,000 | 50,0 | 54,6 | 58,4 | 99,9 |
| 0,125 | 56,0 | 62,6 | 65,8 | 99,9 |
| 0,250 | 62,6 | 71,0 | 73,8 | 99,9 |
| 0,375 | 68,6 | 78,4 | 81,2 | 99,9 |
| 0,500 | 74,7 | 86,8 | 89,2 | 99,9 |
| spread | 24,7 | 32,2 | 30,8 | 0,0 |
Same 1 px stroke, contrast between 50% and 89% depending only on where it sat on the pixel grid. A stroke on the grid comes back roughly half strength with bilinear; one at half-pixel offset comes back at three quarters. On a drawing with hundreds of strokes at arbitrary positions, that reads as blotchy line weight — thin in some places, missing in others, and it moves as the line curves, because the phase changes continuously along the curve.
The native column is the control and it is what makes this a finding rather than an artifact: a render at target resolution is 99.9% at every phase. The unevenness is manufactured by resampling, and the source image never had it.
The same phase sweep on a 2 px stroke, at 2×, 4× and 8×. Worst-phase peak contrast:
| Kernel | 2× | 4× | 8× | halo at 8× |
|---|---|---|---|---|
| bilinear | 87,3% | 93,8% | 95,2% | 0,0% |
| bicubic | 94,3% | 98,5% | 99,4% | 6,5% |
| lanczos | 96,2% | 99,0% | 99,4% | 9,8% |
The worst phase gets better with the scale factor, not worse, for every kernel. The mechanism is simple: at 8× a 2 px stroke covers 16 output pixels, so any single output pixel is far from both flanks and reaches full ink. At 2× it covers 4 pixels and the two flanks overlap in the middle of the stroke.
This is the opposite of the usual advice, and it only holds for contrast, not for cost. Lanczos pays for it with a 9.8% halo — pixel bands brighter than the fill on both flanks — which on flat cel colour is visible as a light outline, whereas bilinear at 8× has no halo at all and still gets to 95.2%.
A 384×384 cel frame with a gentle luma gradient in the fill, so quantisation has something to chew on, encoded at q85 and then upscaled 2× with lanczos. Measured width against the true width:
| True width | Measured after q85 + 2× | Error | Peak contrast |
|---|---|---|---|
| 1 px | 1,683 px | +68,3% | 61,2% |
| 2 px | 2,304 px | +15,2% | 108,3% |
| 3 px | 3,093 px | +3,1% | 105,5% |
| 4 px | 3,887 px | −2,84% | 95,2% |
A 1 px line becomes a 1.68 px smudge — 68% wider than drawn — while a 4 px line is essentially untouched (−2,84%). Thin strokes are the fragile ones, and the damage is already in the file before the upscaler runs. That is why denoising the block grid first is not optional on anime stills: upscaling a compressed 1 px line just enlarges the smudge at 2× its size.
Note the contrast column overshooting 100% at 2 and 3 px. JPEG ringing on the flanks is being counted as extra ink, so those strokes measure wider and darker than they are. Overshoot above 100% is the fingerprint of ringing, not of a thick line.
The page used to say "light sharpening only". Measured on the phase sweep, 1 px stroke, radius 1.0 unsharp mask after a 2× lanczos upscale:
| Unsharp | worst phase | contrast spread | halo |
|---|---|---|---|
| off | 58,4% | 30,8 | 6,1% |
| 50% | 62,6% | 38,7 | 7,9% |
| 100% | 67,2% | 42,0 | 9,8% |
Sharpening does lift the worst phase by 8.8 points, but it widens the spread from 30.8 to 42.0 — it lifts the best phases further than the bad ones. The lines get more contrast overall and more unequal relative to each other, which is the blotchy look you were trying to remove. The halo nearly doubles at the same time.
If the goal is even line weight, the effective move is the opposite of sharpening: enlarge more and do not sharpen, or work from a vector or higher-resolution source. A 1 px source line is under-sampled information; nothing in the pipeline can invent the missing phase.
Self-contained; builds its own fixtures, no input files. Run in an empty directory with numpy and Pillow.
import numpy as np
from PIL import Image, ImageFilter
SS, FILL, INK = 8, 0.92, 0.08
CON = FILL - INK
def canvas(strokes, H=400, W=400, y0=80, y1=320):
c = np.full((H * SS, W * SS), FILL)
for w, x in strokes:
a, b = int(round((x - w / 2) * SS)), int(round((x + w / 2) * SS))
c[y0 * SS:y1 * SS, a:b] = INK
return c.reshape(H, SS, W, SS).mean(axis=(1, 3))
img8 = lambda a: Image.fromarray((np.clip(a, 0, 1) * 255).astype(np.uint8), 'L')
def measure(im, ctr, s, half=6.0):
"""ink integral in source px + darkest core contrast (%) per stroke"""
a = np.asarray(im, np.float64) / 255
r, base = a[int(200 * s)], float(np.median(a[int(150 * s)]))
out = []
for c in ctr:
seg = base - r[max(int(c - half * s), 0):int(c + half * s)]
ink = seg.sum() / CON / s
core = r[int(c) - 1:int(c) + 1].min()
out.append((ink, 100 * (base - core) / CON))
return out
W, C = [1, 2, 3, 4], [48, 100, 152, 204]
canon = canvas(list(zip(W, C)))
ph = [40 + 40 * i for i in range(8)]
ctr = [c + i / 8 for i, c in enumerate(ph)]
# 1px stroke at 8 sub-pixel phases, upscaled 2x
for name, k in [('bilinear', Image.BILINEAR), ('lanczos', Image.LANCZOS)]:
im = img8(canvas([(1.0, c) for c in ctr])).resize((800, 800), k)
cs = [round(cv, 1) for _, cv in measure(im, [c * 2 for c in ctr], 2)]
print(name, cs, 'spread', round(max(cs) - min(cs), 1))
Expected output: bilinear [50.0, 56.0, 62.6, 68.6, 74.7, 68.6, 62.6, 56.0] spread 24.7 and lanczos [58.4, 65.8, 73.8, 81.2, 89.2, 81.2, 73.8, 65.8] spread 30.8. A native 2× render of the same eight strokes returns 99.9% for all eight — that comparison is the whole point.
Line art is only half of an anime frame. The other half is screentone — the dot lattice used for shading — and the standing advice is that any resize wrecks it, so you must descreen before you enlarge. That advice is right in one specific case and wrong in the case most people are actually in. The difference is screen pitch, and it is measurable on a few hundred lines of numpy.
Synthetic, because a real frame cannot give you a ground truth: dots on a rotated square lattice, screen angle 15°, pitch 6 px, ink coverage 50%, which makes the dot radius √(0.5 × 36 / π) = 2.394 px. The pattern is rendered at 8× and then area-averaged down to 300×300, so the source has correct partial coverage instead of aliased hard edges.
The lattice geometry is where my first run of this measurement went wrong, and it is worth
stating because the error is invisible in the output. Dots sit at u, v = (k+½)p
in the rotated frame and the bare paper between four dots sits at u, v = k p,
where u = x·cos θ + y·sin θ. The pattern is anchored to the pixel origin. My
first script sampled around the image centre instead, which walks off the lattice as you
move outward: it printed −111.6 levels at pitch 2.5 px and +18.7 at pitch 4.0 px for what
should be the same quantity, sign flips included. If a screentone measurement gives you a
negative or near-zero depth, the sampling is wrong, not the image.
The check that the sampling is right: run it on the 8× render before averaging. Every dot there is binary, so the depth must read the full 255 levels. It does, at every pitch from 2.5 px up.
| Pitch | GT depth | Source depth | % of GT | Source dot CV |
|---|---|---|---|---|
| 2.0 px | 255.0 | 23.9 | 9% | 7.75% |
| 2.5 px | 255.0 | 82.5 | 32% | 4.84% |
| 3.0 px | 255.0 | 142.1 | 56% | 2.44% |
| 4.0 px | 255.0 | 221.5 | 87% | 0.63% |
| 6.0 px | 255.0 | 254.1 | 100% | 0.02% |
Depth is paper corner minus dot centre in 8-bit levels; CV is the coefficient of variation of ink mass over individual lattice cells. Read the bottom row and the top row as two different problems. At 6 px the source already holds the entire screen, and there is nothing for an upscaler to lose. At 2 px the source holds 9% of it — the screen is at Nyquist and the samples are looking at nearly flat grey. Those two rows behave nothing alike, which is why "does upscaling ruin screentone" has no single answer.
At pitch 6 px, measuring the same corner-minus-centre depth on the upscaled output against ground truth: nearest 100.0%, bilinear 100.0%, bicubic 100.0%, Lanczos 94.9% at 4×. Lanczos is the only kernel that loses anything, and it loses 5% of the depth — the same overshoot that makes it look crisp on edges is shaving the top off the dots. Per-dot ink mass tells the same story from the other side: source floor 0.017%, output 0.21% for nearest, 0.54% for bicubic, 0.86% for Lanczos. And at the patch level — ink mass over a 4×4 block of dots, which is what the eye integrates — every kernel lands on the source's own floor of 0.280% at every integer factor. There is no blotching to see. For a screen at 5 px pitch or coarser, descreening before the upscale buys you nothing you can measure.
Mean tone is the number someone would check first, and it does drift — always in the same direction, always by about the same amount regardless of scale factor:
| Factor | Nearest | Bilinear | Bicubic | Lanczos |
|---|---|---|---|---|
| 1.25× | +0.01 | +0.08 | +0.88 | +1.26 |
| 2× | −0.00 | +0.20 | +0.96 | +1.35 |
| 3× | −0.00 | −0.00 | +0.83 | +1.19 |
| 4× | −0.00 | +0.10 | +0.88 | +1.26 |
It is not a kernel property, and it is not rounding. The same resize in floating point mode — no 8-bit output stage — drifts by 0.00 levels for every kernel. A flat 128 field resizes to 128.000 for all four. What produces the shift is clipping: Lanczos overshoots below 0 on 18.4% of the output pixels, contributing +2.57 levels of brightness, and above 1 on 14.0%, contributing −1.38 levels of darkness. The two do not cancel, because the undershoot is deeper than the overshoot is tall, and everything outside [0, 255] gets pinned to the boundary. Bicubic has the same imbalance at smaller magnitude: 19.1% under at +1.60 against 13.3% over at −0.78, netting +0.82 predicted and +0.96 measured.
Half a percent of brightness is not visible, and if that were the whole story you could ignore it. It matters because it is the same clipping that produces the halo — the measurement just makes it a number instead of an adjective. If you are tiling or stacking many resizes, 1.26 levels per pass compounds.
The per-dot numbers above are all at integer factors, and at integer factors nearest is the cleanest kernel there is — 0.19% at 2× against Lanczos at 0.93%. Move to a fractional factor and nearest falls apart:
| Factor | Nearest | Bilinear | Bicubic | Lanczos |
|---|---|---|---|---|
| 1.1× | 13.65% | 0.77% | 1.16% | 0.94% |
| 1.25× | 2.80% | 0.87% | 0.65% | 0.90% |
| 1.5× | 3.34% | 0.32% | 0.59% | 0.91% |
| 2× | 0.19% | 0.21% | 0.54% | 0.93% |
| 4× | 0.21% | 0.17% | 0.54% | 0.86% |
At 1.1× nearest is 800× the source floor: it duplicates whole pixel columns, so some dots get an extra column and some get none, and the flat tone becomes a lattice of slightly wrong dots. A windowed kernel spreads the damage across neighbours instead, which is why Lanczos sits at 0.78–0.94% whether the factor is 1.1 or 4. At the 4×4-patch level nearest recovers to the source floor at every integer factor but stays at 1.57% at 1.1× and 1.05% at 1.5× — patch-scale unevenness you can see across a large fill, not just dot to dot.
The rule that falls out: integer factor with nearest is fine, any factor with a windowed kernel is fine, fractional factor with nearest is the one combination to avoid. If a tool offers you "1.5×" and no choice of kernel, you are probably getting the bad cell.
This is where the standard advice earns its keep, for a reason different from the one usually given. The source at 2 px pitch has 23.9 levels of depth — 9% of the screen that is physically there. Upscale it 4× with Lanczos and the output has 135.6 levels, 53% of ground truth. The upscaler produced 5.7× the contrast the source contained. Not recovered — produced. The correlation between the output and the ground truth at 2 px is 0.647, against 0.938 at 6 px, so two thirds of that invented contrast is in roughly the right place and a third of it is a moiré pattern the original never had.
| Pitch | Source depth | 4× Lanczos depth | % of GT | Correlation with GT |
|---|---|---|---|---|
| 2.0 px | 23.9 | 135.6 | 53% | 0.647 |
| 2.5 px | 82.5 | 239.7 | 94% | 0.807 |
| 3.0 px | 142.1 | 253.5 | 99% | 0.831 |
| 4.0 px | 221.5 | 254.9 | 100% | 0.887 |
| 6.0 px | 254.1 | 242.1 | 95% | 0.938 |
Notice the non-monotonicity: % of ground truth climbs to 100% at pitch 4 and then falls back to 95% at pitch 6, because at 6 px it is the Lanczos overshoot shaving the dots rather than anything missing. Correlation climbs monotonically, which is the more meaningful column.
A gaussian of σ = 0.5 px on the source, then 2× Lanczos, on the 6 px fixture: per-dot CV falls from 0.927% to 0.239%, dot depth rises from 243.9 to 249.2 levels (96% → 98% of ground truth), and the brightness drift falls from +1.35 to +0.07 levels. A small blur makes the result both more even and more faithful, because it removes the steepest local gradients before the kernel's overshoot gets to them, and there is less to clip.
Past that it turns destructive fast. σ = 0.7 holds depth at 242.3, σ = 0.9 drops to 221.1 (87%), σ = 1.2 to 162.7 (64%). By 1.2 the screen is half gone and no amount of upscaling gets it back, which is the failure mode behind every "I descreened and it went muddy" report. Half a pixel of blur is a repair; one pixel is a different picture.
A real frame arrives as JPEG, so the fixture should too. Encode the 300 px source at descending quality, then 2× Lanczos:
Per-dot CV goes 0.949% at q95 → 0.982% at q90 → 1.016% at q85 → 1.094% at q75 → 1.268% at q60 → 1.362% at q40. Patch-scale CV goes 0.282% → 0.364% over the same range, starting at the source floor and ending above it. So the unevenness at low quality is not created by the upscale; it is already in the file, and the upscale faithfully enlarges it. Denoising for block artifacts before the resize — the earlier section's advice — addresses this directly, and on the numbers here it is the only step that does.
Self-contained, no input files, about twenty seconds.
import numpy as np
from PIL import Image
S, N, TH, P, INK = 8, 300, 15.0, 6.0, 0.5
r = np.sqrt(INK * P * P / np.pi) * S # dot radius in 8x px
p = P * S
yy, xx = np.mgrid[0:N*S, 0:N*S].astype(np.float32)
u = (xx*np.cos(np.deg2rad(TH)) + yy*np.sin(np.deg2rad(TH))) % p - p/2
v = (-xx*np.sin(np.deg2rad(TH)) + yy*np.cos(np.deg2rad(TH))) % p - p/2
cov = np.zeros((N*S, N*S), np.float32)
o = (np.arange(S) + 0.5) / S - 0.5
for oy in o:
for ox in o:
cov += (u-ox)**2 + (v-oy)**2 <= r*r
hi = 1.0 - cov / (S*S)
src = hi.reshape(N, S, N, S).mean(axis=(1, 3)) # correct partial coverage
def sample(a, y, x):
"""bilinear; a nearest lookup biases the depth upward by a level"""
y0, x0 = int(np.floor(y)), int(np.floor(x))
fy, fx = y - y0, x - x0
return (a[y0, x0]*(1-fy)*(1-fx) + a[y0+1, x0]*fy*(1-fx)
+ a[y0, x0+1]*(1-fy)*fx + a[y0+1, x0+1]*fy*fx)
def depth(a, pitch):
"""paper corner minus dot centre, in 8-bit levels"""
h, w = a.shape
c, s = np.cos(np.deg2rad(TH)), np.sin(np.deg2rad(TH))
span = int(min(h, w) / pitch) - 2
cs, gs = [], []
for k in range(-span, span):
for m in range(-span, span):
for (ou, ov), st in (((0.5,0.5), cs), ((0.0,0.0), gs)):
U, V = (k+ou)*pitch, (m+ov)*pitch
x, y = U*c - V*s, U*s + V*c # origin-anchored, NOT w/2
if 1 <= x < w-2 and 1 <= y < h-2:
st.append(sample(a, y, x))
return (np.mean(gs) - np.mean(cs)) * 255
u8 = (src * 255).round().astype(np.uint8)
gt = depth(hi, P*S) # must print 255.0
print("GT", round(gt, 1), "source", round(depth(src, P), 1))
for f, k in ((4.0, Image.LANCZOS), (4.0, Image.NEAREST)):
out = np.asarray(Image.fromarray(u8).resize((int(N*f),)*2, k)) / 255
print(f, k, round(depth(out, P*f) / gt * 100, 1), "% of GT")
Expected: GT 255.0 source 254.1, then 94.9 % of GT for Lanczos
and 100.0 % for nearest at 4×. If the ground-truth line does not read 255.0, the
lattice sampling is off and every number above it is noise. Using a nearest lookup instead of
sample() reads the source at 255.0 rather than 254.1 — one level, which is the
size of the effect being measured, so the interpolation is not optional.
Photo models treat flat fills as missing detail, so they add grain and shading, and they soften hard strokes into gradients. A 2D preset is trained on the opposite.
Only the compression artifacts. Aggressive full-frame denoise blotches flat colour.
Width is safe at any factor — measured error stays under 0.6% at 2× and 4×. The 2× limit is about file size and processing time. What degrades unevenly is stroke contrast against sub-pixel phase, and that improves as the factor grows.
Yes, badly. Block boundaries sit on the line edges and get enlarged along with them.
The 2D preset described here is one of eight in UpgoLAB, browser based, free during launch, no watermark. Full comparison with other tools: four-way comparison.