Urgent.News

What's breaking now, across thousands of outlets.

Tech

Linear Light Upscaling Is Correct, and It Cost Me 18 Shadow Levels

Every resampling article opens with the same demo: downscale a black-and-white checkerboard in sRGB, get a muddy grey that should have been mid-grey, then do it in linear light and get the right answer. The demo is correct. I have reproduced it. Then I took that conclusion — "always resample in linear light" — and applied it to a real 512×512 photograph, and to a shadow gradient, and to an…

The source material discusses various experiments comparing the performance of resampling images in linear light versus sRGB color space. The key points are:

1. Resampling in linear light preserves more high-frequency detail compared to resampling in sRGB. This is because human contrast perception is roughly logarithmic, so resampling in linear light avoids wasting bits in less sensitive areas of the image.

2. However, resampling in linear light also results in worse Peak Signal-to-Noise Ratio (PSNR) compared to sRGB. PSNR is a mean squared error over the whole image, and the linear pipeline spends its error where the eye is most sensitive - in the shadows.

3. The magnitude of the error depends on the brightness of the source pixel. Below brightness value 128, sRGB resampling is more accurate in code values, while above value 128, linear resampling is more accurate. This creates a "crossover" point where the better pipeline depends on the brightness of the pixels being resampled.

4. When a linear intermediate is quantized to 8-bit before storing, it loses some distinct levels compared to the original float buffer. This quantization error manifests as banding in dark shadows, reducing image quality. Keeping the buffer as float avoids this issue, but requires more memory.

5. The source material concludes that the choice between resampling in linear light or sRGB depends on the specific use case and the importance of preserving detail versus minimizing PSNR. For images with a wide range of brightness values, keeping the buffer as float and only converting to sRGB for storage is recommended to maintain the highest image quality.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Cross-validation, and the split that hides a model's failure

Cross-validation is how most models get their score. Six points worked through by hand show how k-fold works, and how the same model scores 0.80 or −0.67 depending only on how the data was split.

  • Cross-validation assesses model performance by splitting data into folds.
  • Hidden flaw: model scores higher when tested on data it saw during training.
  • Group-based cross-validation prevents overfitting to specific data groups.

JSLab is out: write code, watch it run as you type

JSLab is available today for Apple Silicon Macs running macOS 14 or later. It's a native JavaScript and TypeScript scratchpad.

  • JSLab simplifies JavaScript/TypeScript coding on Apple Silicon Macs
  • Code executes and displays output instantly as you type
  • Supports multiple runtimes, npm packages, and AI-assisted code review

Offline-First, Zero Backend: Building a Tailoring Business App That Works Without Internet

Every tailor I know keeps his whole business in paper registers. One notebook for measurements. Another one for orders. Payments live in a third place, which is mostly his memory.

  • TailorVexa is an offline-first app for tailoring businesses, replacing paper registers.
  • No internet required due to inconsistent connectivity and high mobile data costs in target markets.
  • Local storage and security features like PIN and biometric lock ensure fast, secure operation.

More from Sunday 15 November →