I want to calculate the Euclidean distance in RGB space for the pixels of a source and a reference image. This is what I think will work (pseudo code):
src = source image (RGB)
ref = reference image (RGB)
dst = dest image (GREY)
tmp = temporary image (RGB)
AbsDiff(src, ref, tmp) //dest=|src-ref|
ColorToGrey(tmp, dst) //dest=tmp_r + tmp_g + tmp_b
the problem is that src is in 8u format and sqr will get out of range so I have to convert to float32 and back again. I thought about using AddSquare as it can convert to float32 and square together but this requires to zero the accumulation buffer first.
Is there a better solution?
how to get distance in RGB space