Log in

View Full Version : msu super-precision equivalent ?


Mounir
18th January 2011, 04:28
What would be a avisynth filter working like msu super precision, see here (http://www.compression.ru/video/super_resolution/super_precision_en.html) (the which sadly is under license) ?

IanB
18th January 2011, 08:53
It's called intelligent Dithering!

There are few AVS filters that do this sort of thing. AddGrain, SmoothLevels, etc are examples of things close to this, but not quite the same. They all lack the analysis component to automatically add the right amount of noise data.

====================================
Low brow warning - technical content follows :D
====================================

Example :-

If you take an RGB greyscale ramp image it will have values ranging 0 to 255, an entropy of 256 states.

If you convert it to YUV it will have values ranging 16 to 235, an entropy of only 220 states.

If you convert it back to RGB it will still only have an entropy of 220 states of the possible 256 states.

These conversions assume fast integer arithmetic, e.g.typically as used in AVS :-

Y = 16 + (Kr'*R + Kg'*G + Kb'*B + 2^16/2) >> 16

where Kx' = (2^16 * Kx * 219 + 127) / 255; Kr=0.299, Kg=0.587, Kb=0.114

As we are analysing a greyscale image the chroma components, U and V, will be zero (128).

In the reverse direction, simplifying because we know U and V are zero we effectively get :-

R=G=B = ((Y-16) * (255 * 2^16 / 219) + 2^16/2) >> 16

Now the terms in red 2^16/2 are for rounding as is done with Int(float + 0.5). When this term is a constant, as in normally done, the results are fully deterministic. When you do a population analysis on the YUV data you find 36 values have twice the average population when compare to the other 184 values. And when you convert back to RGB, the 36 double population and 184 normal populations values convert 1 for 1 and another 36 values will have zero population. Our nice smooth ramp will have bumps in it.

Now with dithering effectively we replace the rounding term, 2^16/2, with a variable term, say int(2^16*RND()), where RND returns random numbers 0.0 <= N < 1.0. The average is still 2^16/2, but in any specific instance it may be 0 through to 65535.

When we analyse the image populations now we find the YUV image has 220 values each with an average population of 256/220 times the average population for the original image values. And for the re-converted RGB image we have the full 256 states with the original average population distribution. Now it is important to note these are statistics for the average values. Any given pixel will only be within +\-1 of it's original value. This is a manifestation of the noise we added while converting the values. Now most importantly our nice smooth ramp is still smooth ramp, just with a little noise.

Similar logic applies to the 5 bit examples of the MSU Super-Precision Filter, basically the arithmetic is [0..31]*8+int(8*RND())

In real life generating values with a function like RND() takes to long and as with a series of coin tosses an all heads in a row result is a possible outcome. There are cleverer implementations that can be fast and avoid these shortcomings.

frustum
18th January 2011, 18:28
IanB --

I don't follow your logic. If there is some computational process which creates a continuous distribution of values which we then must map to fewer bits, just rounding (or truncating) will produce a banding effect. Dithering will chose values above or below the ideal value in complement to the proximity of the idea value to the available value (that is, if the ideal value has a fraction 10% of the distance to the closest available value, it will be chosen 90% of the time). When passed through a low-pass filter (eg, our eyes at some distance from the screen), it reconstructs a continuous value.

But that isn't what this filter does, I believe. There is no more information available that dithering can tease out. We don't know the original, ideal value at each pixel. I believe in the example they are starting with 5b/component video. Although a ramp along a row of pixels might have once upon a time been 128 ... 144, the filter only knows that the pixels on the left are 128 and the pixels on the right are 144, with no other value in between. Bits [2:0] of each component are zero, so adding dithering will not change anything, resulting in the same stair step but with added noise.

Somehow they have to infer the truncated lsbs. My guess is they do a low-pass filter on the image and then do some type of thresholded selection which indicates that lsbs can be taken from the low-pass version if the adjacent pixel's original values are within +/-1 of the low pass version of the image.

Dark Shikari
18th January 2011, 19:07
Dither filters like gradfun2db do the same thing. They infer the extra bits, and then dither back down to 8-bit. You just want something that doesn't do the last step.

IanB
18th January 2011, 22:09
@frustum,

I did say intelligent dithering. My example was intended to provoke mathematical discussion and be generic using dumb simply random data to fill in the extra bottom bits. The important concepts are 1. Identify the number of active states (220 in my RGB-YUV example, 5 bit (32) in the web page images), and 2. provide a function to assign extra states to create a more visually pleasing image. Your example of low passing the image then using that data to add back the lower bits seems a reasonable idea, there are lots of other algorithms. I hope they get discussed.

Mounir
18th January 2011, 23:16
My first thought was that dithering is in the mix (gradfun2db) but there is more to it. On another (old) thread someone argued that it was the combination of fractal denoising (http://forum.doom9.org/showthread.php?t=110200&highlight=frfun) + gradfun2db

Mounir
23rd January 2011, 04:29
IanB you seem to know a thing or two in avisynth and maths, will you write a script in the near future that mimic msu precision filter's work ? I eagerly look forward to the day this come to fruition, you know that ;)

IanB
23rd January 2011, 21:38
I have just added a Dither option to the Levels filter in CVS. So with that you could do some quantisation dithering, but as for the intelligent analysis you will have to find someone with free time and interest in the project.

For example, in the crudest terms something like this :-...
Levels(0, 1.0, 255, 0, 31) # Crush range back into 5 bits
Levels(0, 1.0, 31, 0, 255, Dither=True) # Expand range with dithering.
...