P = 30*sqrt(|Red1-Red2|))+59*sqrt(|Green1-Green2|))+11*sqrt(|Blue1-Blue2|))
gray
50
|
255
|
10
|
66
|
75
|
30
|
80
|
44
|
1
|
Sqrt(50-75)
Max Diference = Mininum Value – Central
Max Dif = 75-1
75-50 = 25*LumFactor
Possible Structures. Assume smaller then central = 0, bigger then central = 1
50 is smaller then 75, therefore = 0
|
255 is bigger then 75, therefore = 1
|
10
|
66
|
75
|
30
|
80
|
44
|
1
|
Turns onto
Convert it to binary we have
0 1 0 0 75 0 1 0 0
75 is always 0, therefore
0 1 0 0 0 0 1 0 0 = 84
Max Value = 495
Or we can simply disconsider the central bit
0 1 0 0 0 1 0 0 = 044= 68
Or we can calculate the standard deviation of the difference instead
50
|
255
|
10
|
66
|
75
|
30
|
80
|
44
|
1
|
Equals to
50-75
|
255-75
|
10-75
|
66-75
|
75
|
30-75
|
80-75
|
44-75
|
1-75
|
-25
|
180
|
-65
|
-9
|
75
|
-45
|
5
|
-31
|
-74
|
Calculate the std of all the differences except the central number 75
Divide the central number with the standard dev
σ: 75.254567967666
DivisionRatio = 75.254567967666/75 = 1.003394
Now we divide each value with the standard deviation (except the central value 75)
Ex: |25|/75.254567967666 = 0.332206
180/75.254567967666 = 2.391881
65/75.254567967666 = 0.863735
5/75.254567967666 = 0.066441
Etc
From each resultant value we multiply or divide with DivisionRatio. So, if DivisionRatio > 1 we divide. Otherwise we multiply
Ex:
0.332206/1.003394 = 0.331082
2.391881/1.003394 =2.38379
0.863735/1.003394 =0.860813
0.066441/1.003394 =0.066216
In order to find the new numbers we must normalize the results. So, we take the difference of the minimum and the maximum and multiply it with 255 to we get an integer
2.38379 - 0.066216 = 2.317574
Value1 = (0.331082-0.066216)/(2.317574) * 255 = 29.14286
Value2 = (2.38379-0.066216)/(2.317574) * 255 = 255
Value3 = (0.860813-0.066216)/(2.317574) * 255 = 87.42857
Value4 = (0.066216-0.066216)/(2.317574) * 255 = 0
Ok, now we have a whole new set of locally structure data biased on the centered one (Whose value is still 75)
Passing onto our table we wil have:
29.14286
|
255
|
87.42857
|
....
|
75
|
....
|
0
|
...
|
....
|
And again, we can do the smaller then 75 thing to make it binary
Turns onto
Possible Structures. Assume smaller then central = 0, bigger then central = 1
29.14 is smaller then 75, therefore = 0
|
255 is bigger then 75, therefore = 1
|
87 is bigger then turns onto1
|
…
|
75
|
…
|
0
|
…
|
.
|
And we compute he the true binary of it.
Ex: Say we have a binary value resulting in 48
This is our texture/colormatch data. All we have to do is create a table (matrix 9x9) that carries the Luma, Hue and Saturation (or Lab) values and associate it with it the value 48.
Whatever pixel whose color value = 75 and Binary Difference Value = 48 we then search on our tables to be filled.
So we can have a maximum of 256 binary difference values from each pixel on a total of at least 256*256 distinct data with similar structure from each other
Can we do more ? Yes we can.
We can take the Difference table to build a 81x81 pixels, separated with 9x9 quadrants and compare the diff result on each other
Math =
X1
|
X2
|
X3
|
Y1
|
k
|
Y2
|
Z1
|
Z2
|
Z3
|
Mean = ((X1-k)+(X2-k)+(X3-k)+(Y1-k)+(Y3-k)+(Z1-k)+(Z2-k)+(Z3-k))/8
Variance =
1/8 (1/8 (8 k - X1 - X2 - X3 - Y1 - Y3 - Z1 - Z2 - Z3) + X2)^2
F = (8*k-(SumPixels))/8
8*F = 8*k-SumPixels
SumPixels = 8*k-8*F
Variance = (((F+X1)^2)/8) + (((F+X2)^2)/8) +
(((F+X1)^2)/8)+(((F+X2)^2)/8)+(((F+X3)^2)/8)+(((F+Y1)^2)/8)+(((F+Y3)^2)/8)+(((F+Z1)^2)/8)+(((F+Z2)^2)/8)+(((F+Z3)^2)/8)
k^2 - S^2/64 + 1/8 (X1^2 + X2^2 + X3^2 + Y1^2 + Y3^2 + Z1^2 + Z2^2 + Z3^2)
Outro filtro
X1
|
X2
|
X3
|
Y1
|
K
|
Y2
|
Z1
|
Z2
|
Z3
|
T1 = (X1^2)/8+(X2^2)/8+(X3^2)/8+(Y1^2)/8+(Y3^2)/8+(Z1^2)/8+(Z3^2)/8+(Z3^2)/8
T2 = ((X1+X2+X3+Y1+Y3+Z1+Z2+Z3)^2)/64
K=sqrt(T1+T2)/(sqrt(2))
Share with your friends: |