Expand description
Edge-directed (“NEDI-lite”) upscale RGB packed u8 by integer scale 2|3|4.
Classical, no learned weights. For each output pixel we estimate the local gradient direction from the 4 nearest source pixels and interpolate ALONG the edge rather than across it, so diagonal edges stay sharp instead of staircasing/blurring the way plain bilinear does.
Decision (per 2×2 source cell, using a luma proxy r+g+b):
d_main = |l00 - l11|— variation along the main diagonal\(through the top-left / bottom-right corners, which are co-linear on that edge).d_anti = |l10 - l01|— variation along the anti-diagonal/(through the top-right / bottom-left corners). The edge runs along whichever diagonal is flattest. When one diagonal is clearly flatter than the other (and the cell actually contains an edge), we interpolate along that diagonal — averaging the two co-linear neighbours (which are near-equal on a clean edge, so no graying) and ramping across it. Axis-aligned edges and flat regions are left to bilinear, which is already jaggy-free on them; the diagonal case is the whole point of this kernel.
Functions§
- edge_
directed_ lite - Edge-directed upsample RGB8.
out≥w*scale * h*scale * 3. Scale ∈ {2,3,4}.