Jens-Michael Gross said:
Get a 4 bit grayscale image and save it as true color image. Then look
at the color values.
If Photoshop would use *16 for this job, you'll never see an 255 color
value in the resulting image. if you see, it's definitely not using /16
and *16 for the conversion. (or it uses different algorithms for both
directions)
Photoshop (v7.1) doesn't actually support 4 bit images internally (the
first operation it makes on opening a 4-bit image is to convert it to
8-bit indexed colour mode) so the data is assigns to the nominal levels
after that conversion is irrelevant. Furthermore, as Wayne pointed out
in an earlier post, you are now converting from a 4-bit image luminance
descriptor to an 8-bit descriptor - completely the opposite function of
that being addressed in the subject line of the thread!
Photoshop will, however, convert an 8-bit full range image to any number
of levels you chose, using the Posterise function, but retain the data
in 8-bit format. So, create an 8-bit greyscale image with 256 pixels
wide, linearly ramping from 0 to 255 across the image. Do not rely on
the Photoshop gradient tool for this, which introduces a dither to the
data, but, if necessary, create a file directly with a hex editor to be
sure that the numbers are a precise linear ramp with each level
represented by a single pixel width. Select the
Image|Adjustment|Posterise and input 16 as the number of discrete levels
required (ie. a 4-bit range). Please explain why Photoshop then
produces a 16 level ramp with equal widths for all of the 16 levels.
From the original 256 equispaced levels, the lower 16 (neither 8 nor 9!)
are converted to black, the upper 16 (neither 8 nor 9!) are converted to
white, and every level in between is sourced from 16 levels (not 17!) in
the original 8-bit range. In short, in determining which levels of the
0..255 range are being mapped to the 16 level range Photoshop *is*
simply truncating the data.
Same thing happens if you take a 16-bit greyscale image that is 256
pixels wide and create a linear ramp from 0 to 255, then convert that
image to 8-bit greyscale. The resulting linear ramp is again equispaced
indicating that Photoshop has implemented the conversion from 16-bit
data to 8-bit by truncation. (In spite of Chris Cox's comments earlier
in this thread!)
Similarly, Paintshop Pro, which does support 4-bit graphic images
directly will reduce an 256 colour, 8-bit, image to 16 colours (4-bits)
directly. Guess what, that does the same! (Select Colors|Decrease Color
Depth| 16 colors (4-bit)|Optimised Octree - Nearest Color).
Now, just because Photoshop and Paintshop Pro do it that way does not
make it right - there have been numerous bugs and errors in both of
those applications over the years of their development to rely on either
using a "correct" algorithm - however it does put the lie to your
argument that all programs implement the conversion using your preferred
method. Clearly the two most popular image processing packages on the
PC and Mac platforms use a shift right to reduce the number of bits
representing images.