one fing leads . . .

Greyscale for Edge Detection
It may not be a straightforward as that.
The widely – and not so widely – used formulas for edge detection mostly or all argue for converting an image to greyscale before analysis. Follow links to Edge Detection formulas on the Wikipedia page for Edge Detection.
All very well, but they never seem to say what formula they use for converting an image to greyscale.
That can be quite significant as the examples on this page should show. A perceptual edge between two areas of the same brightness calculation (i.e. they would equate to exactly the same shade of grey) can be quite pronounced. You see it as an edge, but if the greyscale conversion doesn’t identify that as as edge because it converts both colours to the same grey, can the edge detection software ever work satisfactorily?
As with many issues relating to relative brightness analysis, this may not matter much in the general sceme of things as the results will be good enough. Though good enough for what? I wonder whether some of the ever more complex mathematics that is being applied to this is the result of the classic academic slipup, charging down the research tunnel when one of the basic concepts is flawed.
T
his page attempts to demonstrate edges. Each block of coloured text has a background and foreground (i.e. text) of equal brightness (i.e. equal greyscale) by brightness calculation. IF CONVERTED TO GREYSCALE, THEREFORE, THERE WILL BE NO EDGES. If you can clearly see edges in the coloured block (as you almost certainly can) then that formula for converting to greyscale is not going to be adequate for edge detection to take place accurately.
For an explanation of the formulas used in these samples see my page Formulas for Calculating Pixel Brightness (i.e. Greyscale)).
N
o formula calculates relative brightness absolutely accurately, see my page Equivalent Colour Brightnesses. For this reason my edge detection routines take hue into consideration as well as greyscale.
See the foot of the page for comments regarding colour blindness.
Demo 1. This uses the oft-recommened Lightness calculation for greyscale, a simple linear formula made by adding the highest of the red, green and blue brightness levels to the lowest, and dividing the result by 2.
Lightness formula at brightness 138
RGB 20,255,20 (green) and 255,20,20 (red) both give a brightness of 138 using the Lightness formula.
Demo 2. This uses the also oft-recommened Average calculation for greyscale, a simple linear formula made by adding the red, green and blue brightness levels together and dividing the result by 3.
Average formula at brightness 138
RGB 79,255,79 (green) and 255,79,79 (red) both give a brightness of 138 using the Average formula.
Demo 3. This uses the YIQ weighted formula factors R: 0.299, G: 0.587, B: 0.114. The YIQ factors applied linearly are those recommended by the WWW consortium (W3C) for determining colour contrast of text on web pages, see W3C Working Draft Checkpoint 2.1.
YIQ weighted formula at brightness 138
RGB 0,235,0 (green) and 255,88,88 (red) both give a brightness of 138 using the YIQ weighted formula.
Demo 4. This uses the sRGB gamma-decompress, weighted sum then gamma-recompress method. formula factors R: 0.2235, G: 0.7154, B: 0.0611 and a gamma exponent of 2.4.
sRGB gamma weighted formula at brightness 138
RGB 0,161,0 (green) and 255,56,56 (red) both give a brightness of 138 using the sRGB gamma-decompress, weighted sum then gamma-recompress method..
Notes:
The first thing to note is that only the gamma-weighted formula gives anything like a perceptual equivalence in terms of brightness with the colours that are chosen for the demo. As you can see below, there are a number of colours that could have been chosen, each giving a greyscale brightness of 138. But the problem is, if any pair of colours will produce a preceptual edge while a conversion to greyscale won’t, there is going to be a probblem when doing edge detection this way.
Colour blindness As is clear by looking at this page, either hue has an effect on edge detection or all the formulas for calculating brightness (i.e. greyscale) are seriously different from what the eye does. If hue does indeed have an effect on edge identifcation, then it logically follows that people with deficient colour vision will be able to detect edges less well that someone whose vision is of the majority. But is that true? I have no idea, I don’t think any research has been done on this. Possibly the more likely answer is that we do not yet have a truly accurate formula for converting a colour image to greyscale.
It is important to be aware that (in our current state of knowledge) for any hue, there is more than one way of forming a given brightness. All the following greens (hue 120°) and reds (hue 0°) are at brightness 138. Brightness Calculation on load uses the sRGB gamma weighted method though you can change this using the checkboxes and radio buttons below to see the effect. The blocks attempt to start at 20% saturation and go up in steps of 5% saturation to 100%.
It won’t take a lot of imagination to see that two colours of equal brightness are going to look much closer to each other the closer they are in saturation.
Brightness Calculation Formula:

more experiments for the sake of my dreams