def decompose_alpha(color, mask, bg)
      components = decompose_alpha_components(color, mask, bg)
      (components.inject(0) { |a, b| a + b } / 3.0).round
    end
def decompose_alpha(color, mask, bg)
      components = decompose_alpha_components(color, mask, bg)
      (components.inject(0) { |a, b| a + b } / 3.0).round
    end
Decomposes the alpha channel value given the resulting color, the mask
 color and a background color, all of which should be opaque.

 Make sure to call {#alpha_decomposable?} first to see if the alpha
 channel value can successfully decomposed with a given tolerance,
 otherwise the return value of this method is undefined.

 @param [Integer] color The color that was the result of compositing.
 @param [Integer] mask The opaque variant of the color that was being
   composed
 @param [Integer] bg The background color on which the color was composed.
 @return [Integer] The best fitting alpha channel, a value between 0 and
   255.
 @see #alpha_decomposable?