2

I am trying to compare images based on their Euclidean Distance. I have come across this pseudo code:

sqrt((r1-r2)^2 + (g1-g2)^2 + (b1-b2)^2)

What I am trying to figure out is- in the pseudo code above, does (r1-r2) mean: subtract red values in image-1 from the red values in image-2?

StepUp
  • 36,391
  • 15
  • 88
  • 148
user1167596
  • 107
  • 1
  • 13
  • 4
    `Does (r1-r2) mean: subtract red values in image 1 from the red values in image 2?` **That's right.** – user3437460 Mar 05 '16 at 14:30
  • 3
    That's how I would interpret it. I'll assume those three coordinates for points 1 and 2 are at a common pixel location in 2D. – duffymo Mar 05 '16 at 14:30
  • one note to keep in mind...r,g,b might be how the pseudo code takes the 3 colour channels into account, but it's worth checking out the CIE L*a*b colour space. You'd calculate the distance the same way, but you'd need to convert from RGB to CIE XYZ then to L*a*b. Have a look at [this answer](http://stackoverflow.com/questions/15438063/how-to-calculate-the-distance-between-ofcolors-in-openframeworks/15721504#15721504) for more details – George Profenza Mar 05 '16 at 19:22

1 Answers1

0

Yeah, this is the most basic form of Euclidean Color Distance. You compare pixel color to other pixel color by comparing the distance between the different components in the pixels.

Pixels are 3 colors (usually) in RGB and you compare the pixels. So you #FFAA00 and #F8A010 has 0xFF for R1 and 0xF8 for R2.

There's a bunch of other distance values like CIELabD2k. But, that's the core behind color distance.

Tatarize
  • 10,238
  • 4
  • 58
  • 64