def to_type_with_rgb(dest)
      if typecode < RGB_
        if dest < FLOAT_
          lazy { r * 0.299 + g * 0.587 + b * 0.114 }.to_type dest
        elsif dest < INT_
          lazy { (r * 0.299 + g * 0.587 + b * 0.114).round }.to_type dest
        else
          to_type_without_rgb dest
        end
      else
        to_type_without_rgb dest
      end
    end
def to_type_with_rgb(dest)
      if typecode < RGB_
        if dest < FLOAT_
          lazy { r * 0.299 + g * 0.587 + b * 0.114 }.to_type dest
        elsif dest < INT_
          lazy { (r * 0.299 + g * 0.587 + b * 0.114).round }.to_type dest
        else
          to_type_without_rgb dest
        end
      else
        to_type_without_rgb dest
      end
    end
Convert RGB array to scalar array

 This operation is a special case handling colour to greyscale conversion.

 @param [Class] dest Element type to convert to.

 @return [Node] Array based on the different element type.