lib/chunky_png/color.rb
# Compute the Euclidean distance between 2 colors in RGBA
#
# This method simply takes the Euclidean distance between the RGBA channels
# of 2 colors, which gives us a measure of how different the two colors
# are.
#
# Although it would be more perceptually accurate to calculate a proper
# Delta E in Lab colorspace, this method should serve many use-cases while
# avoiding the overhead of converting RGBA to Lab.
#
# @param pixel_after [Integer]
# @param pixel_before [Integer]
# @return [Float]
Compute the Euclidean distance between 2 colors in RGBA
This method simply takes the Euclidean distance between the RGBA channels
of 2 colors, which gives us a measure of how different the two colors
are.

Although it would be more perceptually accurate to calculate a proper
Delta E in Lab colorspace, this method should serve many use-cases while
avoiding the overhead of converting RGBA to Lab.
Compute the Euclidean distance between 2 colors in RGBA This method simply takes the Euclidean distance between the RGBA channels of 2 colors which gives us a measure of how different the two colors are . Although it would be more perceptually accurate to calculate a proper Delta E in Lab colorspace this method should serve many use - cases while avoiding the overhead of converting RGBA to Lab .
def euclidean_distance_rgba(pixel_after, pixel_before)
      return 0.0 if pixel_after == pixel_before
      Math.sqrt(
        (r(pixel_after) - r(pixel_before))**2 +
        (g(pixel_after) - g(pixel_before))**2 +
        (b(pixel_after) - b(pixel_before))**2 +
        (a(pixel_after) - a(pixel_before))**2
      )
    end
def euclidean_distance_rgba ( pixel_after , pixel_before ) return 0.0 if pixel_after == pixel_before Math . sqrt ( ( r ( pixel_after ) - r ( pixel_before ) ) ** 2 + ( g ( pixel_after ) - g ( pixel_before ) ) ** 2 + ( b ( pixel_after ) - b ( pixel_before ) ) ** 2 + ( a ( pixel_after ) - a ( pixel_before ) ) ** 2 ) end
Compute the Euclidean distance between 2 colors in RGBA
This method simply takes the Euclidean distance between the RGBA channels
of 2 colors, which gives us a measure of how different the two colors
are.
Compute the Euclidean distance between 2 colors in RGBA This method simply takes the Euclidean distance between the RGBA channels of 2 colors which gives us a measure of how different the two colors are .
None
Float
pixel_after
<not_specific>
pixel_before
<not_specific>
<not_specific>
None