ImageMagick, What does Q8 vs Q16 actually mean?
Asked Answered
G

2

15

Under Windows, I need to choose between Q8 and Q16. I know that Q8 are 8 bits-per-pixel component (e.g. 8-bit red, 8-bit green, etc.), whereas, Q16 are 16 bits-per-pixel component. I know also that Q16 uses twice memory as Q8. Therefore, I must choose carefully.

What is a 16 bits-per-pixel component? Does a jpeg image support 16 bits-per-pixel component? Does a picture one takes from a digital camera in a smartphone result in 8 bits-per-pixel component or 16 bits-per-pixel component?

I just need to load jpg images, crop/resize them and save. I also need to save the pictures in 2 different variants: one with the icc color profile management included and another without any icc profile (sRGB)

Gilly answered 22/2, 2018 at 21:44 Comment(0)
S
15

What is a 16 bits-per-pixel component?

Each "channel" (e.g. Red, Green, Blue) can have a value between 0x0000 (no color), and 0xFFFF (full color). This allows greater depth of color, and more precision calculations.

For example. A "RED" pixel displayed with QuantumDepth of 8...

$ convert -size 1x1 xc:red -depth 8 rgb:- | hexdump 
0000000 ff 00 00                                       
0000003

Same for QuantumDepth go 16 ...

$ convert -size 1x1 xc:red -depth 16 rgb:- | hexdump 
0000000 ff ff 00 00 00 00                              
0000006

And for Q32..? You guessed it.

$ convert -size 1x1 xc:red -depth 32 rgb:- | hexdump 
0000000 ff ff ff ff 00 00 00 00 00 00 00 00            
000000c

All-n-all, more memory is allocated to represent a color value. It gets a little more complex with HDRI imaging.

does jpeg image support 16 bits-per-pixel component ? does picture we take from camera in smartphone are in 8 bits-per-pixel component or 16 bits-per-pixel component ?

I believe JPEG's are 8bit, but I can be wrong here. I do know that most photographers KEEP all RAW files from device because JPEG doesn't support all the detail captured by the camera sensor. Here's a great write-up with examples.

I just need to load jpg images, crop/resize them and save. I also need to save the pictures in 2 different variants: one with the icc color profile management included and another without any icc profile (sRGB)

ImageMagick was designed to be "Swiss-Army-Knife" of encoders & decoders (+ a large amount of features). When reading a file, it decodes the format into something called "Authenticate Pixels" to be managed internally. The default size of the internal storage can be configured at time of compile, and for convenience the pre-build binaries are offered as Q8, Q16, and Q32. Plus additional HDRI support.

If your focused on quality, Q16 is a safe option. Q8 will be way faster, but limiting at times.

Skye answered 22/2, 2018 at 22:14 Comment(2)
thanks emcconville, but i don't understand, if JPEG are in 8 bit is their any advantage to use Q16 ?Gilly
Yes/No. JPEG's are lossy by design; so in theory, decoding the coefficients will have higher precision. But in no way will it add missing data resulting in a higher quality image.Skye
G
1

Also, you can find answer here (.net package, but means the same) : https://github.com/dlemstra/Magick.NET/tree/main/docs#q8-q16-or-q16-hdri

Q8, Q16 or Q16-HDRI?

Versions with Q8 in the name are 8 bits-per-pixel component (e.g. 8-bit red, 8-bit green, etc.), whereas, Q16 are 16 bits-per-pixel component. A Q16 version permits you to read or write 16-bit images without losing precision but requires twice as much resources as the Q8 version. The Q16-HDRI version uses twice the amount of memory as the Q16. It is more precise because it uses a floating point (32 bits-per-pixel component) and it allows out-of-bound pixels (less than 0 and more than 65535). The Q8 version is the recommended version. If you need to read/write images with a better quality you should use the Q16 version instead.

Germaine answered 21/2, 2022 at 22:9 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.