Page 2 of 2

Re: Fuzz culculator

Posted: 2013-08-16T10:14:20-07:00
by fmw42
Now I need to know what value can be u.r, u.g, u.b?
Internally IM scales values to the range 0 to 1. That is the u representation. u.r is red channel. After doing the match, you need to convert back to normal color range by multiplying by quantumrange (Q16=65535). However, you can apply the same formula in normal Q range if you want using each color in the range 0 to quantumrange or 0 to 255 (however, you want to see the values) or even multiply by 100 for percent.

Re: Fuzz culculator

Posted: 2013-08-24T05:50:18-07:00
by VanGog
I have spent some time with study. Finaly I have found what is RMSE difference.

Here we are,
http://en.wikipedia.org/wiki/Mean_square_error
fuzz < sqrt( color_distance^2 * u.a*v.a + alpha_distance^2 )

line 1776

For example for an RGB
color_distance^2 = ( (u.r-v.r)^2 + (u.g-v.g)^2 + (u.b-v.b)^2 ) / 3
However which formula did you use from the formulas used on wiki?

What does mean the u and what does mean the v. Which one of the objects keeps values to be expected (the color which I look for/the color which I expect to find) and which one keeps the value which is actually read from input (file image/screen/clipboard image, etc).

Basicly I am asking, if I pick red to look for (RGB 255 0 0) but I have found cyan (RGB 255 0 255) in the source image, should I do this?

color_distance^2 = ( (255-255)^2 + (0-0)^2 + (0-255)^2 ) / 3[/quote]
or
color_distance^2 = ( (255-255)^2 + (0-0)^2 + (255-0)^2 ) / 3[/quote]

Also when I look into your code color.c line 1871-1882 so it does not look like you would use this formula there.

this looks like

Code: Select all

distance = color_value^2 * fuzz

that would assume to have both fuzz and pixel in same units/same scale.
but is not MRSE difference.

Re: Fuzz culculator

Posted: 2013-08-24T06:44:09-07:00
by snibgo
VanGog wrote:Basicly I am asking, if I pick red to look for (RGB 255 0 0) but I have found cyan (RGB 255 0 255) in the source image, should I do this?

color_distance^2 = ( (255-255)^2 + (0-0)^2 + (0-255)^2 ) / 3
or
color_distance^2 = ( (255-255)^2 + (0-0)^2 + (255-0)^2 ) / 3
It doesn't matter as the results are the same.

This is the general formula for finding the distance in 3-D space from point u to point v, and normalising so the maximum result is 1. You can measure from u to v, or from v to u. The distance is the same.

Re: Fuzz culculator

Posted: 2013-08-24T08:47:13-07:00
by VanGog
So fmw42 or who is the author of the code has to have some function to convert the colors to 3D space.. I have read a pdf file

http://www.google.cz/url?q=http://www.f ... uGS5C3lHtg

3. RGB Color-Matching Functions
4. XYZ Coordinates
5. XYZ Primaries
6. XYZ Color-Matching Functions
7. Chromaticity Values
8. Color Space Visualization
9. Color Temperature and White Points
10. CIE RGB Gamut in xyY
11. Color Space Calculations
...
27 Appendix A Color Matching
29 Appendix B Further Explanations for Chapter 5
30 CIE Color Space

There are some formulas but not sure if it is relative with the topic. E.g. page 30 contains apendix about Photometric luminance, there are come convertions already build-in but I don't belive this is what IM uses in his convertion functions.

(I will likely delete this citation later becasue it is long and out of topic)
Appendix B Further Explanations for Chapter 5

Chapter 5 has always been enigmatic - since the beginning about ten years ago .
Now I am very grateful to Monsieur Jean-Yves Chasle for giving further explanations, here posted un-changed.

Photometric luminance of color (page 4)

The CIE Photopic Luminous Efficiency function V is related to r_bar, g_bar and b_bar:

V(?) = 1.0000*r_bar(?) + 4.5907*g_bar(?) + 0.0601*b_bar(?) (1)

The theorical light efficacy k equals 683 lm/W, based on the luminous flux measured at around 555 nm where

V(?) equals 1. As on page 4, considering a light with a spectral power diffusion P

in W/sr.m2, the photometric luminance (in cd/m2) can be calculated as:
L = k*integral{P(?)*V(?)*d?} (2)

where k is the efficacy of the source light.

Substituting (1) in (2):
L = k*integral{P(?)*(1.0000*r_bar(?) + 4.5907*g_bar(?) + 0.0601*b_bar(?))*d?}
= 1.0000*k*integral{P(?)*r_bar(?)*d?} + 4.5907*k*integral{P(?)*g_bar(?)*d?} +
0.0601*k*integral{P(?)*b_bar(?)*d?}

Using notations from page 4 (in cd/m2):

L = 1.0000*R + 4.5907*G + 0.0601*B (3)
in cd/m2.

The photometric luminance (in cd/m2) can be separated in terms of tristimulus values Lr, Lg and Lb:

Lr = 1.0000*R (4)
Lg = 4.5907*G (5)
Lb = 0.0601*B (6)
Lr, Lg and Lb represent the photometric luminance (in cd/m2) at each wavelength (700, 546.1 and 435.8 respectively). These luminances are reported on the graph named „R,G,B“ on page 4 and 6 for a matched white light of coordinates (1,1,1) in the CIE RGB space. In practice, the light efficacy k is less than 683 lm/W. In [1], Hunt publishes samples of this value depending on the light type (page 75-79, and table 4.2 page 97).

Application (page 6)
These results can be applied on page 6, where X = 1, Y = 0 and Z = 0 representing X in the CIE XYZ space is converted to the CIE RGB space in order to evaluate its photometric luminance at each wavelength (700, 546.1 and 435.8 respectively):
R = +2.36461*X - 0.89654*Y - 0.46807*Z = +2.36461
G = -0.51517*X + 1.42641*Y + 0.08876*Z = -0.51517
B = +0.00520*X - 0.01441*Y + 1.00920*Z = +0.00520

in colorimetric luminance of red, green and blue.
From (4), (5) and (6):
Lr = 1.0000*R = 1.0000 * +2.36461 = +2.36461
Lg = 4.5907*G = 4.5907 * -0.51517 = -2.36499
Lb = 0.0601*B = 0.0601 * +0.00520 = +0.00031

(in cd/m2)
These luminances are reported on the graph named „X“ on page 6. Using (3), they sum to 0 as expected. Same calculations for Y and Z, leading to the graphs named „Y“ and „Z“ on page 6.
PS:
I believe if you want to convert colors to 3D space you need to convert to x,y coordinates. But I did not understand how to do this convertion from the pdf description. Not enough examples.

Much more interesting is page 24 which ScreenShot I paste here (I can change it to link if admin wishes):
Image

So I think I understand how they calculate the colors but not how the convert from RGB to xyY and from xyY to RGB (I am not sure if I say this right, is it xyY namespace?).

Re: Fuzz culculator

Posted: 2013-08-24T10:13:15-07:00
by fmw42
So I think I understand how they calculate the colors but not how the convert from RGB to xyY and from xyY to RGB (I am not sure if I say this right, is it xyY namespace?).
I did not write any of this.

I believe most of the colorspace conversions come from Bruce Lindbloom's mathematics and coded by the IM developers. See

http://www.brucelindbloom.com/index.htm ... lator.html
http://www.brucelindbloom.com/index.htm ... lator.html

Re: Fuzz culculator

Posted: 2013-08-24T14:01:35-07:00
by snibgo
VanGog wrote:So fmw42 or who is the author of the code has to have some function to convert the colors to 3D space.
Huh? The colours are already in 3D space. The 3 dimensions are the 3 channels, which are typically Red, Green and Blue.

Re: Fuzz culculator

Posted: 2013-08-24T14:56:06-07:00
by fmw42
I believe what user snibgo means is that IM -fuzz does not care what colorspace is being used. However, it is best to use an orthogonal color space (all axes are perpendicular).