# Edge Detection with a special algorithm

Studying for my finals in Image Processing. Trying to solve the following question:

An image processing specialist recommended an algorithm for Edge Detection in a color image RGB. He argued that it was unnecessary to switch to a different color model. You can calculate the gradient in each of the three images R, G and B, and calculate a new vector which is the sum of the gradients. Using the sum of the gradients we find the edges. Why is he wrong?

The solution was:

Consider color of figure $$C_{\text{Figure}}^{\text{RGB}}=\left(100,0,0\right)$$ and color of background $$C_{\text{Background}}^{\text{RGB}}=\left(0,100,0\right)$$. The gradient of the red color element will be the same size as that of the green color element but their marks will be opposite so we will get the sum of the gradients to be zero, even though there is an actual edge.

I'm trying to understand the solution. I understand that in theory you will get the same size, but why they are opposite? How do I move from the color into the gradient, mathematically speaking? Is it possible to provide a more "formal" argument?

• Hi! Do you understand what the gradient of an image is? Feb 7 at 14:23
• It's kind of a dumb argument. A reasonable person would look at the sum of the absolute values or squares of the gradient. You are looking for a change and it doesn't matter if the change goes up or down. A change is a change. Feb 7 at 15:07
• @Hilmar: It's teaching that sometimes a person from out of town with a briefcase and a big hourly rate isn't always better at the job than a monkey wearing a Rolex. Feb 7 at 15:27
• @TimWescott: I think it's more that teachers need to learn how to ask meaningful and relevant questions instead of making up random stuff. Feb 8 at 14:39

I'm going to just hand you the answer, but check your notes. The hint is that it's called a color vector. Mathematically, you treat it as a 3-element vector like any other. This means that you can do arithmetic on it; i.e. $$C_2^{RGB} - C_1^{RGB} = \left ( c^R_2 - c^R_1, c^G_2 - c^G_1, c^B_2 - c^B_1\right )$$.
If you treat $$C^{RGB}$$ as a vector, then the rest should be obvious.