image-rs / image-rs/image

Use case: decode Radiance HDR image, upload into video memory

Open
#548 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind: new features
Dominant language
Rust
Stars
5.9k
Forks
723
Avg merge
1h 56m
Merged PRs (30d)
4

Description

Radiance HDR image format uses 4-byte shared exponent representation. Decoding it into a vector of RGB<f32> pixels, then recompressing it into, say, RGB9_E5_EXT requires 3 times more memory than really needed, thanks to the Pixel trait.

EDIT: I found out that implementing Pixel trait is optional, but still, refactoring Pixel trait seems reasonable.

Pixel trait is responsible for

  1. enforcing storage format (from_slice, channels methods constraint underlying representation to [Subpixel; n_channels])
  2. providing color conversions
  3. providing various color operations (notice that invert() doesn't make sense for shared exponent format)
  4. providing mutable access to underlying pixel storage.

It is too much for a single trait.

What do you think about splitting Pixel into ColorConvert, ChannelArrayStorage, ColorOperations?

ImageBuffer becomes

impl<RawPixel, Container> ImageBuffer<RawPixel, Container> 
where Container: Deref<Target=[RawPixel]> { ...

RawPixel type will be implementing ColorConvert and other traits as appropriate.

Pixel trait will be defined for RawPixel where RawPixel: ColorConvert + ChannelArrayStorage + ColorOperations to maintain backward compatibility.

EDIT: ImageBuffer should be left as is, Deref trait exposes underlying storage.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Pixel trait, ImageBuffer, and the Radiance HDR decoding path mentioned in the issue. Review how storage, color conversion, color operations, and mutable access are currently coupled; done means a decided trait design that supports shared-exponent pixels while preserving the stated backward-compatibility requirements.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-vision
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.