Color to grayscale algorithm

@solub
If the RGB components are extracted using

        r = red(col)  
        g = green(col)
        b = blue(col)

What would these line then be?

        # Calculate the true relative luminance using scaled weights:
        lum = (weight_R * r + weight_G * g + weight_B * b) >> 8  # Bit-shift by 8 (dividing by 256)
        
        # Set the grayscale pixel by combining the luminance value into RGB format
        lum_img.pixels[i] = (col & 0xff000000) | (lum << 16) | (lum << 8) | lum

Please and thank you,