Log in

View Full Version : Decimal values for RGB


luquinhas0021
15th April 2015, 19:08
Let's consider RGByyy (y is included in natural numbers). The number of possible colors in this system is given by y x y x y. But, what will happens with number of colors of this system if y is included in rational numbers, like y = 125.55. The number of colors will increase or will keep the same of when y is, for example, y = 125?
I will take a chance and I will make other ask: if I have a upscaling of x times, being x a natural number, 1 pixel of source image will be turned into x pixels. But, if x is a rational number, for example 5,25, there's no way of I turn 1 pixel into 5,25, just into 5. So what I do with the 0,25? or any other.
x can be in line or in column.

vivan
15th April 2015, 19:33
Yes, to represent the exact result of scaling you need higher or even infinite precision.
To represent it with limited precision you need to either round or dither it down.

luquinhas0021
15th April 2015, 20:10
Be a x times in line upscaling or downscaling, or y times in column upscaling downscaling, or xy times upscaling or downscaling, being x and y of form a,b, a and b different of 0. Multiply the rational number for a natural number until find the first result that is a natural number, and then do the upscaling or downscaling of this factor. Examples:
a) A upscaling in line or in column, 2.25 times:
2.25 x 1 = 2,25; 2.25 x 2 = 5.5; 2.25 x 3 = 6.75; 2.25 x 4 = 9; 2.25 x 5 = 11.25,..., 2.25 x 8 = 18,... Then, the first number that multiplied by 2.25 give a natural number result is 4. Then, we do a upscaling of 9 times (3 x 3 in case of line and column) and then, downscaling of 4 times.

b) A downscaling in line or in column, 2.25 times:
Do the same thing of above example, just, in this case, do the downscaling of 9 times, and then upscaling of 4 times.
What did you think?

The "problem" is, when number is infinitesimal, is necessary multiply it for 10, 100, 1000,... And this makes the process get so much slow. By this, is there some other way to do this?

vivan
15th April 2015, 20:30
And how the fact that 2.25 = 9/4 is related to your decimal "problem"?

And decomposition is not the problem - you know your source and target resolution, simplifying that fraction is trivial (i.e. 1280 -> 1920 means 1920/1280 = 3/2).

luquinhas0021
15th April 2015, 20:40
You didn't understand.

1) The problem start to hapeens when the number is so infinitesimal, like 3.1415. Certainly the minor number you have multiply 3.1415 for the result to be a natural number is big. If I'm not wrong, is 10000. 3.1415 x 10000 = 31415. Now think in upscaling or downscaling of 31415 times and a downscaling or upscaling of 10000 times! So computationally expensive, hum?
Course this example is theoretical, but gives a problem notion.
And doesn't exist decomposition. Is this way of this examples:

1920 x 1080 to 2048 x 1080 or 2048 x 1080 to 1920 x 1080: upscaling or downscaling, only in columns, of 1.0666667 times
2560 x 1440 to 2560 x 1600 or 2560 x 1600 to 2560 x 1440: upscaling or downscaling, only in lines, of 1,111111 times.
1920 x 1080 to 2560 x 1440 or 2560 x 1440 to 1920 x 1080: upscaling or downscaling of 1.33 x 1.33 times.
1920 x 1080 to 2730 x 1440 or 2730 x 1440 to 1920 x 1080: upscaling or downscaling of 1.42 x 1.33 times.

vivan
15th April 2015, 21:14
Course this example is theoretical, but gives a problem notion.
And doesn't exist decomposition. Is this way of this examples:

1920 x 1080 to 2048 x 1080 or 2048 x 1080 to 1920 x 1080: upscaling or downscaling, only in columns, of 1.0666667 times
2560 x 1440 to 2560 x 1600 or 2560 x 1600 to 2560 x 1440: upscaling or downscaling, only in lines, of 1,111111 times.
1920 x 1080 to 2560 x 1440 or 2560 x 1440 to 1920 x 1080: upscaling or downscaling of 1.33 x 1.33 times.
1920 x 1080 to 2730 x 1440 or 2730 x 1440 to 1920 x 1080: upscaling or downscaling of 1.42 x 1.33 times.2048/1920 is not a valid fraction? 1600/1440? 2560/1920? 2730/1920? Of course they are.

Anyway you say that your problem is that scaling produce fracional results.
0) Upscaling and downscaling is equal to directly scaling (unless you use different functions).
1) Downscaling always produces fractional results.
2) Even second-to-worst - bilinear upscaling produces fractional results.
3) Real scaling algrorithms (lanczos, etc.) use irrational weights.

Why does perfect precision matters for you?

luquinhas0021
15th April 2015, 21:20
2048/1920, thus like 1440/1080, is valid fraction, but they produce RATIONAL results. I guess, no offense to you, you must study mathematical conjuncts. Just by this way you will understand me.
Anyway, you seem so wise.
The precision of upscaling or downscaling factor, before multiplication, is FP16. After, is integer.

Asmodian
15th April 2015, 22:11
vivan's point 0) seems to cover it, doesn't it? Why upscale above and then downscale instead of simply scaling to the target resolution? You still end up with fractional results.

FP16 is enough precision that no special tricks are needed.

But, if x is a rational number, for example 5,25, there's no way of I turn 1 pixel into 5,25, just into 5. So what I do with the 0,25? or any other.
x can be in line or in column.

This is what dithering is for.

pandy
16th April 2015, 08:41
you must study mathematical conjuncts.

I would recommend you to study areas like quantization and requantization, sampling and resampling, and floating point limitations, rounding errors and error distribution, oversampling is also useful from your perspective.
All your questions are answered from long time.