I'm not sure my method is 100% right, but I think you might check and decide:
1. Add a fill layer and fill iti with 50% grey, then set it to Difference.
2 Add a Threshold layer, then move its cursor all the way to the left until you'll get your picture completely white.
3. Move the cursor towards the right and stop when you see the first group of pixels turned black and zoom with cmd+9 on it-
4. Activate the Info panel and put a marker on the first pixel turned black.
5. Turn grey and Threshold layers off; now you can see that the pixel under the marker is actually almost grey 50%. You can check its color code in the Info panel; let's say,, for instance, its color is 130, 120, 120.
6. Since you want it to become exactly a 128,128,128 pixel you have to add a Curve layer and set it to RGB mode, then you have to click on the Selector button and…
7.1. In the Curve floating window, select the red channel, clic on the marker on the picture and correct its value by dragging until R turns from 130 to 128.
7.2 Correct the other two values the same way, by turning G and B values from 120 to 128.
8. If the result is good for you, delete grey and Threshold layers and merge the picture and curve layer. That's it.
Please, give me your feedback if you guess my method is helpful, but especially if you check that it doesn't work at all.