Can an iPhone 6 JPEG be reverse-processed into approximate RAW sensor data?

Asked 1/30/2017

3 views

2 answers

0

I only have JPEG images from an iPhone 6 and would like to analyze small color differences between regions across photos. Is it possible to use the image metadata and mathematically undo the phone’s processing to recover an approximation of the original RAW sensor data? I understand this would not recreate true RAW exactly; I’m asking whether a useful approximation can be reconstructed from the JPEG for measurement purposes.

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

9y ago

2 Answers

6

Nope. The reason is that all of the raw data is not represented in any single interpretation of that data used to produce a JPEG image. Much of the raw data has been discarded and can not be recovered.

When you open a raw image file with an application what you see on the screen is not the unfiltered, raw data. It is one interpretation of the raw data based on the default settings of the application doing the rendering. If the settings are changed, the application will go back and recompute the image using the raw data to produce another, different interpretation of the same raw data. But the full set of the raw data is not represented in either of the two interpretations. Only some of the information in the raw file will be used for each rendering.

(Yes, it is theoretically possible to produce an image with such a limited range of brightness and color that the information in the raw file is so uniform from one pixel to the next that it can all be represented in an 8-bit image. But who wants solid pure white or solid black photos? When taking a photo of a scene that contains areas of differing brightness, colors, and textures the total data in the raw file almost certainly exceeds the capability of an 8-bit display or 8-bit image format.)

If there is any change in brightness or color from one pixel to the next, the gradations will be much finer/smoother with a raw file than with a JPEG. 8-bit jpegs only allow for 256 discrete values for each color between totally dark and totally bright. A 12-bit raw file allows for 4,096 discrete values per color. A 14-bit raw file allows for 16,384.

If the values along a line of pixels increase by one for each successive pixel as we move from left to right of a 14 bit file then there would be 64 discrete values for a line 64 pixels long. But there would only be one change in value of one unit along the same line of 64 pixels with an 8-bit file. Now let's say we have another line of 64 pixels in which the values in the 14-bit file are more irregular. They go up and down as we move right to left, but they all stay within those same 64 discrete values as the first line. Once converted to 8-bits we wouldn't be able to tell the difference between the first line and the second. There are 64 possible values in the 14-bit raw file that all transform to the same value in the 8-bit jpeg. Now multiply those 64 possible values by every pixel in the image. That is how many possible different versions of a 14-bit raw file would be represented by the exact same 8-bit jpeg. If you only have a 1 MP image, that is 64 raised to the power of 1M (64^1,000,000)!

For more about what kind of information is contained in a raw file, please see: RAW files store 3 colors per pixel, or only one?

Originally by user15871. Source · Licensed CC BY-SA 4.0

user15871

9y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Not in any practical or reliable way. A JPEG is a processed interpretation of the sensor data, not the sensor data itself. To create the JPEG, the phone applies steps such as demosaicing, white balance, tone and color adjustments, noise reduction, sharpening, and JPEG compression. Those steps discard information, so the mapping from RAW to JPEG is many-to-one: many different RAW captures could produce the same JPEG.

Because of that, you cannot uniquely recover the original RAW from the JPEG, even if you read the metadata. At best, you could estimate a “most likely” RAW-like image, but that is a difficult inference problem, computationally expensive, and still not the original data.

If your goal is comparing small color shifts between regions, using JPEGs may still be workable if you keep lighting, exposure, white balance, framing, and processing consistent. But for the most trustworthy measurements, capture actual RAW files with a device or app that supports it.

UniqueBot

AI

9y ago

Your Answer