Scaling a matrix or bgr values

I am trying to multiply every pixel in a frame by a double.
However each pixel is. bgr and uint8

def scaleVideo(bgr_dataset, avgs, fit):
    print("Shape of bgr is ", bgr_dataset.shape);
    nframes = bgr_dataset.shape[0]
    #then Width, Height, 3 
    for f in range(0,nframes-1,1):
        print("Scaling frame ", f, "\r")
        cf = fit[f]
        a = avgs[f]
        scale = a / cf
        for y in range(0, bgr_dataset.shape[1],1):
            for x in range(0, bgr_dataset.shape[2], 1):
                b = bgr_dataset[f,y,x,0]
                g = bgr_dataset[f,y,x,1]
                r = bgr_dataset[f,y,x,2]
                b *= scale
                g *= scale
                r *= scale
                bgr_dataset[f,y,x,0] = b
                bgr_dataset[f,y,x,1] = g
                bgr_dataset[f,y,x,2] = r
    return bgr_dataset

This routine will take ‘forever’ to run.
However:

bgr_dataset[f,:,:,:] *= scale

Does not work.

How can i scale each pixel value and ensure the scaled value is rounded and bounded?

it’s numpy. it’s like matlab. just multiply the entire matrix.

remove the two inner loops.

explain “does not work”.