Pages: 1 ... 3 4 [5] 6 7 ... 9   Go Down

Author Topic: How to convince Sony to do lossless raw on A7RII and others?  (Read 71152 times)

Jim Kasson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2370
    • The Last Word
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #80 on: June 26, 2015, 11:10:03 am »

Very good analysis, Jim.  If those routines are still around it wouldn't be too hard to implement Luke's idea below with a natural image, would it? ;-)


Not too hard. There are three obstacles, all probably surmountable.

The first is that I'm hard at work on my book and the new synthetic slit scan project.

The second is that it'll take me a while to remember how to set up the scripts to do the processing. You've seen my Matlab code. While I subscribe to the theory that a computer program is a communication with those who will come after and only incidentally with the computer that will run it, I never seem to be able to turn that maxim into practice.

The worst example I ever saw of this was thankfully not written by me. When I worked at hp, there was a bug in a 2116A ADC driver. I took a look at the code. It was written in assembler, which needs comments more than Matlab. There were pages of commentless code. Finally I saw a comment next the the instruction CMA,INA, which complements the A register and increments the result by one. The comment, repeated here in its entirety, was, "Make A negative."

The fact that the companding code is embedded in the camera simulator means there's more code to re-understand. It shouldn't take very long, but it's my least favorite programming task.

The third is finding a good candidate image. And that raises the Clintonian question, since which image would be good depends on the definition of good in this context. Is a good image one that will show a big difference after companding? Just what are we trying to discover/prove here?

I could use some help with that last one.

Jim

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 797
    • Hikes -more than strolls- with my dog
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #81 on: June 26, 2015, 02:57:25 pm »

 
Not too hard. There are three obstacles, all probably surmountable.

Didn't mean to put you in the spot, Jim, so don't feel that you need to do anything.

Quote
The comment, repeated here in its entirety, was, "Make A negative."

:)

Quote
The third is finding a good candidate image. And that raises the Clintonian question, since which image would be good depends on the definition of good in this context. Is a good image one that will show a big difference after companding? Just what are we trying to discover/prove here?

My own curiosity is whether Sony's 11-bit lossy compression can be made to give up the ghost in certain situations after aggressive PP.  By that I mean that processing both uncompressed and compressed images equally, the compressed one clearly shows loss of visual information compared to the other.  Based on past experience there will be a qualitative element to marginal differences ('if you add noise to those blocked blacks in image 1 they look no better or worse than those noisy blacks in image2') but if there are significant differences they should make themselves known rather easily.

If and when you may want to do it, perhaps it would be useful to put more than one image through the routines.  How about something with sharp corners and something landscapy with a smooth gradient, or even the classic slanted lamp on a wall?  Luke?  Everyone else?

Jack
Logged

Jim Kasson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2370
    • The Last Word
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #82 on: June 26, 2015, 03:40:41 pm »


My own curiosity is whether Sony's 11-bit lossy compression can be made to give up the ghost in certain situations after aggressive PP.  By that I mean that processing both uncompressed and compressed images equally, the compressed one clearly shows loss of visual information compared to the other.  Based on past experience there will be a qualitative element to marginal differences ('if you add noise to those blocked blacks in image 1 they look no better or worse than those noisy blacks in image2') but if there are significant differences they should make themselves known rather easily.

If and when you may want to do it, perhaps it would be useful to put more than one image through the routines.  How about something with sharp corners and something landscapy with a smooth gradient, or even the classic slanted lamp on a wall?  Luke?  Everyone else?


I've demonstrated that, with synthetic images, you can see the artifacts if you push hard enough in post, but it isn't easy to get the problems to show their ugly heads. I'm not sure what it would prove to do that with real images. We know there are a few out there.

Also, as I think about it, changing the code to work with real raw files isn't trivial; I need to provide a path into the camera simulator for real raw files or take the companding code and port it to its own class. In addition, I'd have to demosaic the images in Matlab. I still haven't figured out how to write raw files that can be decoded with just any raw developer.

Jim

BrianVS

  • Full Member
  • ***
  • Offline Offline
  • Posts: 164
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #83 on: June 26, 2015, 05:16:20 pm »

The last A/D driver I wrote was 15 years ago, I needed an optical feedback loop. Take 1 A/D sample, Do 1 D/A conversion. The software that came with the card expected an array for each call to the driver, did the full setup for the A/D and waited for the pre-amp to settle with each call. Mine ended up being 100x faster for the job required.

If I get some time- will look at implementing the algorithm in FORTRAN. It does not look hard, dimension each row as (2, 16, n/ 32) where n is the number of pixels in each row. Apply the gamma curve, find max/min, compute differences from the min and scale to (Max-Min) to store as 7-bits. Reverse and restore.  My code is setup to do conversions on batches of images, just tell it where the path to the DNG files. I've been using it to convert 14-bit linear DNG files from the M Monochrom to 16-bits using a Gamma curve. The idea is the extra 2-bits prevents collisions. I had fun digging out code that started in the 1980s and having it process DNG. The last time I used it- TIFF 6.0 was brand new and my Wife had a 1MPixel microscope camera that stored all of the images in 1 TIFF file. Nothing would process past the first image, so I wrote her a code to Unpack them. Also wrote code to implement her algorithm to identify and count cancer cells in the image.
Logged

BrianVS

  • Full Member
  • ***
  • Offline Offline
  • Posts: 164
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #84 on: June 26, 2015, 09:45:39 pm »

According to the Rawdigger explanation- the first 256 values of the 11-bit compressed table all get converted to output intensity 0. That seems very wasteful way to preserve a Black value. The DNG files store Black Level as a parameter in the SUB-IFD. The 14-bit to 11-bit compression table seems to be tabular with just a few bin sizes. Same with the decompression. This is not an optimal way of doing things, if this explanation is actually how the Sony scheme works. I'm starting with a 22-bit to 11-bit square root compression, then implement the 7-bit difference frame- which is how the artifacts spread across a larger 3x32 segment of the image, after color-demosaic.
Logged

logeeker

  • Newbie
  • *
  • Offline Offline
  • Posts: 6
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #85 on: June 26, 2015, 10:40:00 pm »

SAR said Sony is going to make the a7R II have the feature of uncompressed RAW by a firmware update.
However, I'm bit worry of that it finally become a lossy uncompressed RAW file.
Logged

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 797
    • Hikes -more than strolls- with my dog
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #86 on: June 27, 2015, 06:51:29 am »

I've demonstrated that, with synthetic images, you can see the artifacts if you push hard enough in post, but it isn't easy to get the problems to show their ugly heads. I'm not sure what it would prove to do that with real images. We know there are a few out there.

Hi Jim,  I may have misinterpreted this post of yours but I thought I had understood that as far as the 14 (or whatever) to 11 bit compression sans delta (what I am interested in) you had not gone as far as checking loss of visual information, i.e. two equally processed images side by side, one compressed one not, the latter showing more visual information than the former.  I know this can be easily done at 8-bits, I know I could not see any sign of it at 9.5 bits with my 12-bit D90 and 11.5 with my 14-bit D610, so I am curious about Sony's 11 bit implementation (no delta, I think they'll kill that).

Also, as I think about it, changing the code to work with real raw files isn't trivial; I need to provide a path into the camera simulator for real raw files or take the companding code and port it to its own class. In addition, I'd have to demosaic the images in Matlab. I still haven't figured out how to write raw files that can be decoded with just any raw developer.

Don't worry about it, Jim.  But in any case nothing wrong with demosaicing in Matlab imo.

Jack
Logged

BrianVS

  • Full Member
  • ***
  • Offline Offline
  • Posts: 164
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #87 on: June 27, 2015, 08:42:22 am »

The Sony compression scheme does more than just compressing to 11-bits/decompressing to 14-bits. The 7-bit delta function is where things go horribly bad. The 7-bit scheme is scaled to cover the max-min range within the strip. It loses the 11-bit Bin number for the decompression, and can cause a much larger difference from the original.

This is more like an 8-bit compression scheme where the error is spread across a sub-image and you just hope there is not much going on to trigger it.
Logged

Jack Hogan

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 797
    • Hikes -more than strolls- with my dog
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #88 on: June 27, 2015, 08:51:21 am »

The Sony compression scheme does more than just compressing to 11-bits/decompressing to 14-bits. The 7-bit delta function is where things go horribly bad. The 7-bit scheme is scaled to cover the max-min range within the strip. It loses the 11-bit Bin number for the decompression, and can cause a much larger difference from the original.

This is more like an 8-bit compression scheme where the error is spread across a sub-image and you just hope there is not much going on to trigger it.

Got it Brian.  Perhaps I should try to understand Sony's raw better before switching to visual mode.

Jack
Logged

BrianVS

  • Full Member
  • ***
  • Offline Offline
  • Posts: 164
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #89 on: June 27, 2015, 10:36:42 am »

To answer the original question-

Make a T-Shirt with a pathological case image designed to cause the Sony compression algorithm to fail. Give it away to new Sony camera owners family and friends.

Label it "Sony! Wear it in the Raw."
Logged

KAHA

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 53
    • www.davidpoata.com
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #90 on: July 13, 2015, 08:20:44 am »

I'm not sure if any one's seen this post from Rishi Sanyal (technical editor at dpreview) regarding Sony's lossy Raw....

Quote
"Just to clarify - lossy Raw does not mean a 1-2 EV dynamic range cost. It means that b/c of the encoding, there can be artifacts around high contrast edges; it doesn't, to our knowledge, have any effect on dynamic range (other than that huge pushes can show some artifacts, but that's not the noise you traditionally associate with poor dynamic range).

Also, the 12-bit ADC mode is a totally separate issue. As long as you're not shooting continuous, or Bulb mode, or have Long Exposure NR turned on and the camera actually uses it (b/c you have a longer than 2s exposure), or you're shooting continuous mode, or bracketing... as long as you're not doing any of these things, you get full 14-bit capture.

But, it is kind of obnoxious that doing any of those things switches the camera into a mode that sacrifices a good deal of dynamic range. For example, how ironic is it that if you bracket your shot to deal with a high DR scene, your camera's DR drops?

That's pretty annoying, in my book."
Logged

AlterEgo

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1995
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #91 on: July 13, 2015, 11:20:25 am »

I'm not sure if any one's seen this post from Rishi Sanyal (technical editor at dpreview) regarding Sony's lossy Raw....
seriously ? this thread has many people whom you shall read before anything "technical editor at dpreview" might want to say...
Logged

Jim Kasson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2370
    • The Last Word
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #92 on: July 13, 2015, 01:36:09 pm »

seriously ? this thread has many people whom you shall read before anything "technical editor at dpreview" might want to say...

True, but what Rishi said was accurate, IMHO, except for the part about being about being able to get 14-bit precision sometimes.

Jim

AlterEgo

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1995
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #93 on: July 13, 2015, 02:07:06 pm »

True, but what Rishi said was accurate, IMHO, except for the part about being about being able to get 14-bit precision sometimes.
and which camera __with new raw implementation__ from Sony does get truly full 14 bit precision then ?
Logged

BrianVS

  • Full Member
  • ***
  • Offline Offline
  • Posts: 164
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #94 on: July 13, 2015, 02:24:18 pm »

Dynamic range is a very different issue than bit depth. A sensor with high dynamic range and low bit-depth is "analogous" to a low-gamma film. A large change in intensity is required to change the output in the A/D. This is related to spatial resolution: if you cannot differentiate changes in intensity, details will become lost in the intensity contour. The Sony camera uses 11-bits a/d conversion and a non-linear scale to fake 14-bit values. Resolution is lost as the slope of the analog/digital conversion is reduced. why have 42MPixels if you are going to kill resolution by skimping on the A/D converter?

The KAF-1600 used in my 22 year old DCS200 has a linear dynamic range of 74dB. 8-Bit A/D. The first Digital Infrared Sensor that I worked on in 1981 used 12-bits, and the second one in 1984 used 15 bits. (They were expensive) Linear dynamic range has not changed that much since the KAF-1600, certainly not the same order of magnitude as megapixels. Prices have dropped. the DCS200 was $12,400- but mine is full-spectrum, was an extra $4K.
« Last Edit: July 13, 2015, 02:31:04 pm by BrianVS »
Logged

Jim Kasson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2370
    • The Last Word
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #95 on: July 13, 2015, 03:20:10 pm »

and which camera __with new raw implementation__ from Sony does get truly full 14 bit precision then ?

None, AFAIK. The cRAW 13 -> 11 tone compression algorithm ignores a 14th bit, if present.

Jim

Jim Kasson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2370
    • The Last Word
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #96 on: July 13, 2015, 03:28:48 pm »

Dynamic range is a very different issue than bit depth. A sensor with high dynamic range and low bit-depth is "analogous" to a low-gamma film.

I don't get the analogy. Please elucidate.

A large change in intensity is required to change the output in the A/D. This is related to spatial resolution: if you cannot differentiate changes in intensity, details will become lost in the intensity contour.

All that depends on how much Pre-ADC dither is present.

The Sony camera uses 11-bits a/d conversion and a non-linear scale to fake 14-bit values.

How do you know that the ADCs are 11 bits?

Resolution is lost as the slope of the analog/digital conversion is reduced. why have 42MPixels if you are going to kill resolution by skimping on the A/D converter?

In my testing and simulations, the cRAW compression/expansion does not affect resolution, as measured by MTF50 or MTF30.

Jim

AlterEgo

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1995
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #97 on: July 13, 2015, 03:43:11 pm »

None, AFAIK.
and technical editor has way higher obligation to be precise with his words vs a regular poster - that is the point of being an editor... that is about mr Rishi of DPReview.
Logged

BrianVS

  • Full Member
  • ***
  • Offline Offline
  • Posts: 164
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #98 on: July 13, 2015, 05:11:02 pm »

A low gamma film requires a large change of intensity of light to produce a change in density. A film with high gamma requires a smaller change of intensity to  for s similar change of density. A sensor with a high dynamic range and low bit-depth requires a large change of intensity to change the value of the pixel. The Leica M246 requires 8 times the change in level of light to increment the output of the a/d converter compared to a Leica M Monochrom.
Logged

Jim Kasson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2370
    • The Last Word
Re: How to convince Sony to do lossless raw on A7RII and others?
« Reply #99 on: July 13, 2015, 06:02:52 pm »

A low gamma film requires a large change of intensity of light to produce a change in density. A film with high gamma requires a smaller change of intensity to  for s similar change of density. A sensor with a high dynamic range and low bit-depth requires a large change of intensity to change the value of the pixel.

Not with proper dithering.

Jim
Pages: 1 ... 3 4 [5] 6 7 ... 9   Go Up