This is a bug possibly connected to an unfixed 6-years old bug regarding the value for 50% gray in 16-bit mode in some Photoshop dialog boxes, see: https://feedback.photoshop.com/photoshop_family/topics/photoshop_uses_the_wrong_50_gray_as_the_neutr...
The problem:
Using Apply Image (Blending: Add, Opacity: 100%, Scale: 1, Offset: -128) on two 50% gray (RGB values of: 16384) layers in 16-bit mode produces non-50% gray layer.
Steps to reproduce (with correct 50% gray value of 16384):
- Create an empty document in 16-bit mode (of any size)
- Create an empty layer, named "A". Delete the background layer.
- Fill the layer "A" with 50% gray (Edit>Fill: Contents 50% Gray)
- Use the Info panel, read RGB values in 16-bit mode of the Info panel: 16384, in 8-bit mode: 128
- Duplicate the layer "A", name it "B". Make sure the layer "B" is an active layer.
- Image>Apply Image: Layer: A, Blending: Add, Scale: 1, Offset: -128
- Read the resulting value: 16320 (in 16-bit mode of the Info panel), 127 (in 8-bit mode of the Info panel)
Expected: 16384 in 16-bit mode of the Info panel and 128 in 8-bit mode of the Info panel.
Steps to reproduce (with incorrect 50% gray value 16448):
- Create an empty document in 16-bit mode (of any size)
- Create an empty layer (alt-click the "new layer" icon), named "A" in the "Soft Light" mode, with checked "Fill with Soft-Light-neutral color (50% gray)". Change the mode to Normal. Delete the background layer.
- Use the Info panel, read RGB values in 16-bit mode of the Info panel: 16448 (different from the previous one), in 8-bit mode: 128 (the same as the previous one)
- Duplicate the layer "A", name it "B". Make sure the layer "B" is an active layer.
- Image>Apply Image: Layer: A, Blending: Add, Scale: 1, Offset: -128
- Read the resulting values didn't change: 16448 (in 16-bit mode of the Info panel), 128 (in 8-bit mode of the Info panel)
Possible cause:
Apply Images uses an incorrect way for converting -128 (8-bit) to a 16-bit value.
Is: convert_8bit_to_16_bit(128) -> 16448,
Should be: convert_8bit_to_16_bit(128) -> 16384.
Workaround (with some losses):
We want to calculate: for layers A and B create the layer C with pixel values of:
"50% gray" + ((A - "50% gray") + (B - "50% gray")) (clipped at 100% black and white)
1) For layers A and B, shift the correct 50% gray point (16384) to the incorrect one (16448) using the Levels adjustment (NOT the Adjustment layer!) with "input white = 254". We are loosing some data.
RackMultipart20181028214096742-40be9124-73af-4e73-9519-3fbc8920d7a6-852546474.png
2) Use the Apply Image as above.
3) Convert the result to the correct 50% gray point (16384) using the Levels Adjustment Layer, with "output white = 254".
RackMultipart201810281175713xq-0f513546-e53e-4bc2-9ab1-ee968eaa7ce6-1299189073.png
We fall one short of all values near 50% gray (for example we get 16383 instead of 16384 for 50% gray), so we have to add "+1" to all pixel values in 16-bit mode. Tricky. Create a Fill Layer, Mode: Linear Dodge (Add), Opacity: 1%, Fill: 50%, Color #010101.
RackMultipart20181028876pdcqja-1c80c5af-7f10-4c1b-be06-bc0f54dbe7ce-5028913.png
Select layer A, Merge (Ctrl+E). Delete layer B.