Compression and Image Quality Metrics
Sending a smaller image is convenient until compression removes a detail your model needs.
Compression and Image Quality Metrics explained visually
Sending a smaller image is convenient until compression removes a detail your model needs. English captions are optional and start off. The complete transcript follows the written lesson.
What you will learn
Sending a smaller image is convenient until compression removes a detail your model needs.
Choose a storage tradeoff
We need to send inspection images to another team without losing tiny scratches. Smaller files are convenient, but the storage choice affects what can be recovered. Lossless compression reproduces the stored pixel values exactly after decoding. Lossy compression allows changes to save more space.
Use metrics with context
For photographs, a jay-peg copy can show blocks or ringing at stronger compression. For a label mask where zero, one, and two name three classes, altered pixel values can change the meaning entirely. Choose a format and loading path that preserve the mask's labels and data type. If transparency matters, check that it survives too.
Inspect what matters
Compare decoded copies against the same source. Mean squared pixel error measures differences after alignment; a structural score examines local patterns. Neither replaces an inspection of small scratches. A high overall score can hide one lost mark, and a slight shift can make pixel error large without destroying the scene.
A worked example
Keep a lossless master and test any viewing copies on the actual recognition task. Next, we'll combine our processing steps into one documented inspection pipeline.
Worked example
A mask uses values zero, one, and two for three classes. A lossy save could introduce other values or alter boundaries. A lossless save preserves the stored labels, provided the software also preserves the image mode and data type during loading and writing.
Quick check: test your understanding
Try it yourself: Choose a format for an editable class-ID mask and one for a compact preview photograph. Explain the different goals.
Check the reasoning
Use a suitable lossless format for the mask. A JPEG preview may be acceptable when small size matters and the original remains available.
Does the highest whole-image quality score guarantee the best small-object visibility?
No. An average metric can underrepresent a small but important region.
How would you solve the practice case?
Use a suitable lossless format for the mask. A JPEG preview may be acceptable when small size matters and the original remains available.
What does the worked example show?
A mask uses values zero, one, and two for three classes. A lossy save could introduce other values or alter boundaries. A lossless save preserves the stored labels, provided the software also preserves the image mode and data type during loading and writing.
Further reading
Digital Image Processing, 4th edition — Rafael C. Gonzalez and Richard E. Woods.
Original ToolsInVision teaching examples. Editorial approach · Suggest a correction
Accessible referenceLesson 15 transcript174 words · Video transcript · Matches the published narration and captionsOpen transcript
We need to send inspection images to another team without losing tiny scratches. Smaller files are convenient, but the storage choice affects what can be recovered. Lossless compression reproduces the stored pixel values exactly after decoding. Lossy compression allows changes to save more space.
For photographs, a jay-peg copy can show blocks or ringing at stronger compression. For a label mask where zero, one, and two name three classes, altered pixel values can change the meaning entirely. Choose a format and loading path that preserve the mask's labels and data type. If transparency matters, check that it survives too.
Compare decoded copies against the same source. Mean squared pixel error measures differences after alignment; a structural score examines local patterns. Neither replaces an inspection of small scratches. A high overall score can hide one lost mark, and a slight shift can make pixel error large without destroying the scene.
Keep a lossless master and test any viewing copies on the actual recognition task. Next, we'll combine our processing steps into one documented inspection pipeline.