JuliaImages / JuliaImages/juliaimages.github.io

How to set bit depth when saving files?

Open
#260 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
33
Forks
52
PR merge metrics
No merged PRs in 30d

Description

I am trying to save a bitmap with a specific bit depth. However, regardless of the type of an image, when I save it as a bitmap, it ends up with bit depth 24. I cannot find anything in the documentation when I search for "bit depth". How can I accomplish this?

A minimal working example is as follows:

using Images, FileIO
#dir = "/path/to/dir"
im_large = n0f16.(Gray.(rand(100,100)))
save(dir * "large.bmp",im_large)
im_small = n0f8.(Gray.(rand(100,100)))
save(dir * "small.bmp",im_small)

Both saved bmp files end up having bit depth 24 on my system (Windows 10).

Edit: It seems that this issue has to do with the number of channels. Even though my images above are supposedly greyscale, the images are saved with three color channels (all having equal values). An 8-bit bmp should have just a single channel.

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 tracing the save(..., ".bmp") path used in the minimal Julia example and checking the existing documentation for image types and channels. Document how BMP bit depth is controlled, or clearly state the supported behavior and limitation; done means the example's result and the answer to the question are explained in the documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.