Regression in bit depth reduction?
Posted: 2010-05-21T14:54:03-07:00
If one has a 16 bit (channel bit depth) image and saves that to a 8 bit quality file format, an implicit bit depth reduction is done. That implicit bit depth reduction should be same as the explicit "-depth 8" operation.. Is that correct?
(At least the documentation seems to imply that.)
If yes, then the implicit bit depth reduction has been changed or broken.
Try this:
# ImageMagick pixel enumeration: 1,3,255,rgb
0,0: (220,220,220) #DCDCDC gainsboro
0,1: (221,221,221) #DDDDDD rgb(221,221,221)
0,2: (219,219,219) #DBDBDB grey86
The first and third pixel values are wrong (according to the 'Gray' formula here).
But I get the correct values with an explicit '-depth 8':
# ImageMagick pixel enumeration: 1,3,255,rgb
0,0: (221,221,221) #DDDDDD rgb(221,221,221)
0,1: (221,221,221) #DDDDDD rgb(221,221,221)
0,2: (220,220,220) #DCDCDC gainsboro
I'm using IM v6.6.1-10 Q16, on Windows XP.
So, without the explicit '-depth 8' operation, a value of '219.886' (third pixel here; 16 bit representation: 0xDCBF) gets reduced to 219. Of course this was only an example. The slight errors occur with all sorts of operations. I just found out after some greyscale conversions when the values were lower than expected. All 8bit file formats (as output) like JPG, PNG8, GIF, etc. are affected. You only get 'correct' values by adding '-depth 8'.
I think this was introduced in version 6.6.0-6. Older versions produce a correct output - with and without '-depth 8'.
(At least the documentation seems to imply that.)
If yes, then the implicit bit depth reduction has been changed or broken.
Try this:
Code: Select all
convert xc:"rgb(220,221,220)" xc:"rgb(220,222,220)" xc:"rgb(220,220,219)" -append -colorspace gray test1.bmp
convert test1.bmp test1.txt
0,0: (220,220,220) #DCDCDC gainsboro
0,1: (221,221,221) #DDDDDD rgb(221,221,221)
0,2: (219,219,219) #DBDBDB grey86
The first and third pixel values are wrong (according to the 'Gray' formula here).
But I get the correct values with an explicit '-depth 8':
Code: Select all
convert xc:"rgb(220,221,220)" xc:"rgb(220,222,220)" xc:"rgb(220,220,219)" -append -colorspace gray -depth 8 test2.bmp
convert test2.bmp test2.txt
0,0: (221,221,221) #DDDDDD rgb(221,221,221)
0,1: (221,221,221) #DDDDDD rgb(221,221,221)
0,2: (220,220,220) #DCDCDC gainsboro
I'm using IM v6.6.1-10 Q16, on Windows XP.
So, without the explicit '-depth 8' operation, a value of '219.886' (third pixel here; 16 bit representation: 0xDCBF) gets reduced to 219. Of course this was only an example. The slight errors occur with all sorts of operations. I just found out after some greyscale conversions when the values were lower than expected. All 8bit file formats (as output) like JPG, PNG8, GIF, etc. are affected. You only get 'correct' values by adding '-depth 8'.
I think this was introduced in version 6.6.0-6. Older versions produce a correct output - with and without '-depth 8'.