The brightness of an image can be measured by the below function as this paper mentioned
In this paper, they didn't talk about Cr, Cg and Cb. Can anyone explain this function?
Thanks in advance.
The coefficients (0.241, 0.691, 0.068) are used to calculate the luminance
For example:
If you have a color (RGB) image and you want to convert to greyscale:
The coefficients are recommended by ITU-BT709 and are standards for HDTV.
So for calculating the brightness the accepted coefficients are 0.241, 0.691, and 0.068.
UPDATE: Check more about new coefficients here.
You can print the brightness values:
import cv2
import numpy as np
# img will be BGR image
img = cv2.imread("samurgut3.jpeg")
#When we square the values overflow will occur if we have uint8 type
img = np.float64(img)
# Extract each channel
Cr = img[:, :, 2]
Cg = img[:, :, 1]
Cb = img[:, :, 0]
# Get width and height
Width = img.shape[0]
Height = img.shape[1]
#I don't think so about the height and width will not be here
brightness = np.sqrt((0.241 * (Cr**2)) + (0.691 * (Cg**2)) + (0.068 * (Cb**2))) / (Width * Height)
#We convert float64 to uint8
brightness =np.uint8(np.absolute(brightness))
print(brightness)
Output:
[[4.42336257e-05 4.09825832e-05 4.09825832e-05 ... 3.44907525e-05
4.13226678e-05 4.13226678e-05]
[4.09825832e-05 4.09825832e-05 4.09825832e-05 ... 3.44907525e-05
4.13226678e-05 4.13226678e-05]