Hi,
If I load a 24 bit RGB image (suppose a PNG) using the Q16 library, how will be mapped the values [0-255] of each pixel in memory? For example, suppose Pixel(0,0) is RGB(10,10,20). Once loaded in memory using Q16, I'll found again (10,10,20) or other values?
I tryied to print on screen a pixel value using cout << pSourceImage->red and I got a value > 34000!
Thank you.
Loading a 24 bit RGB image using Q16 will change pixel value
Re: Loading a 24 bit RGB image using Q16 will change pixel value
8-bit pixels are mapped to 16 by multiplying by 257.
Re: Loading a 24 bit RGB image using Q16 will change pixel value
Thank you. Why this conversion take place? Isn't it more simple to copy the values as is? So, as I'll need to use also the HDR library, what conversion will be done in that case?magick wrote:8-bit pixels are mapped to 16 by multiplying by 257.
Thank you!
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Loading a 24 bit RGB image using Q16 will change pixel value
A Q16 compiled IM defines the internal data structure used to hold and process the image. All images being read in will need to map to this data structure and thus that internal quality standard. Many operations need the extra quality provided by 16 bit values. For some operations you need to use HDRI floating point quality for internal storage.
of course if you are just converting images (as many Window users do) a Q8 version of IM will be faster, and then the input will be represented in memory as 8 bit values, but some operators may show 'quantum rounding effects', especially when multiple operations and color enhancements are being applied to the same in-memory image.
See IM Examples, Basics section on Quality and Depth.
of course if you are just converting images (as many Window users do) a Q8 version of IM will be faster, and then the input will be represented in memory as 8 bit values, but some operators may show 'quantum rounding effects', especially when multiple operations and color enhancements are being applied to the same in-memory image.
See IM Examples, Basics section on Quality and Depth.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Loading a 24 bit RGB image using Q16 will change pixel value
Is there any method or setting in the library that will revert back manually or automatically every pixel to the original value (/257) without having to do in manually one by one? I don't need to do any modification on loaded images, but only to read pixel to do some calculations. As I'll use 8bit and 16bit images, I need Q16, but it would be userful to have 8 bit images loaded with pixel values "as is" using Q16.anthony wrote:A Q16 compiled IM defines the internal data structure used to hold and process the image. All images being read in will need to map to this data structure and thus that internal quality standard. Many operations need the extra quality provided by 16 bit values. For some operations you need to use HDRI floating point quality for internal storage.
of course if you are just converting images (as many Window users do) a Q8 version of IM will be faster, and then the input will be represented in memory as 8 bit values, but some operators may show 'quantum rounding effects', especially when multiple operations and color enhancements are being applied to the same in-memory image.
See IM Examples, Basics section on Quality and Depth.
Thank you
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Loading a 24 bit RGB image using Q16 will change pixel value
Why 257? I would have expected it was 256.magick wrote:8-bit pixels are mapped to 16 by multiplying by 257.
Pete
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Loading a 24 bit RGB image using Q16 will change pixel value
It is 257 because you do not have a value of 256, QuantumRange (or MaxRGB) is 255.
As such to map an 8-bit 255 to 16-bit 65355 is multiply by 257.
In HEX this is #FF -> #FFFF and NOT #FF -> #FF00
If you only multiplied by 256 your white will become off-white!
As such to map an 8-bit 255 to 16-bit 65355 is multiply by 257.
In HEX this is #FF -> #FFFF and NOT #FF -> #FF00
If you only multiplied by 256 your white will become off-white!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Loading a 24 bit RGB image using Q16 will change pixel value
AHA. So instead of having an 8-bit intensity mapped from hex AB to a 16-bit AB00 (which is what I thought would be done), it maps to ABAB and this does indeed map to the right 16-bit intensity. Cool.
Pete
Pete
Re: Loading a 24 bit RGB image using Q16 will change pixel value
So, I'll need to manually divide by 257 each pixel of the image to get back the original values?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Loading a 24 bit RGB image using Q16 will change pixel value
when processing your image, you can force it to 8-bits by adding -depth 8