Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to make an image more vibrant in colour using OpenCV?

I need to enhance few of the images before processing them. I need to enhance their colour.

I found a post online that shows how to determine how colour an image actually is.

Computing image “colorfulness” with OpenCV and Python

Code

def image_colorfulness(image):
    # split the image into its respective RGB components
    (B, G, R) = cv2.split(image.astype("float"))

    # compute rg = R - G
    rg = np.absolute(R - G)

    # compute yb = 0.5 * (R + G) - B
    yb = np.absolute(0.5 * (R + G) - B)

    # compute the mean and standard deviation of both `rg` and `yb`
    (rbMean, rbStd) = (np.mean(rg), np.std(rg))
    (ybMean, ybStd) = (np.mean(yb), np.std(yb))

    # combine the mean and standard deviations
    stdRoot = np.sqrt((rbStd ** 2) + (ybStd ** 2))
    meanRoot = np.sqrt((rbMean ** 2) + (ybMean ** 2))

    # derive the "colorfulness" metric and return it
    return stdRoot + (0.3 * meanRoot)

For my application the threshold value seems to be 24.00 lesser than this I need to enhance the colour for my application to work properly

I used Gimp tool to enhance the colour

image description

Reduce curve for the colour to be more enhanced

image description

How can I enhance colour of an image in a similar manner using OpenCV?

How to make an image more vibrant in colour using OpenCV?

I need to enhance few of the images before processing them. I need to enhance their colour.

I found a post online that shows how to determine how colour an image actually is.

Computing image “colorfulness” with OpenCV and Python

Code

def image_colorfulness(image):
    # split the image into its respective RGB components
    (B, G, R) = cv2.split(image.astype("float"))

    # compute rg = R - G
    rg = np.absolute(R - G)

    # compute yb = 0.5 * (R + G) - B
    yb = np.absolute(0.5 * (R + G) - B)

    # compute the mean and standard deviation of both `rg` and `yb`
    (rbMean, rbStd) = (np.mean(rg), np.std(rg))
    (ybMean, ybStd) = (np.mean(yb), np.std(yb))

    # combine the mean and standard deviations
    stdRoot = np.sqrt((rbStd ** 2) + (ybStd ** 2))
    meanRoot = np.sqrt((rbMean ** 2) + (ybMean ** 2))

    # derive the "colorfulness" metric and return it
    return stdRoot + (0.3 * meanRoot)

For my application the threshold value seems to be 24.00 lesser than this I need to enhance the colour for my application to work properly

I used Gimp tool to enhance the colour

image description

Reduce curve for the colour to be more enhanced

image description

How can I enhance colour of an image in a similar manner using OpenCV?

How to make an image more vibrant in colour using OpenCV?

I need to enhance few of the images before processing them. I need to enhance their colour.

I found a post online that shows how to determine how colour an image actually is.

Computing image “colorfulness” with OpenCV and Python

Code

def image_colorfulness(image):
    # split the image into its respective RGB components
    (B, G, R) = cv2.split(image.astype("float"))

    # compute rg = R - G
    rg = np.absolute(R - G)

    # compute yb = 0.5 * (R + G) - B
    yb = np.absolute(0.5 * (R + G) - B)

    # compute the mean and standard deviation of both `rg` and `yb`
    (rbMean, rbStd) = (np.mean(rg), np.std(rg))
    (ybMean, ybStd) = (np.mean(yb), np.std(yb))

    # combine the mean and standard deviations
    stdRoot = np.sqrt((rbStd ** 2) + (ybStd ** 2))
    meanRoot = np.sqrt((rbMean ** 2) + (ybMean ** 2))

    # derive the "colorfulness" metric and return it
    return stdRoot + (0.3 * meanRoot)

PS:

B,G,R = image[...,0],image[...,1],image[...,2]

seems to be 20X faster than

(B, G, R) = cv2.split(image.astype("float"))

For my application the threshold value seems to be 24.00 lesser than this I need to enhance the colour for my application to work properly

I used Gimp tool to enhance the colour

image description

Reduce curve for the colour to be more enhanced

image description

How can I enhance colour of an image in a similar manner using OpenCV?

How to make an image more vibrant in colour using OpenCV?

I need to enhance few of the images before processing them. I need to enhance their colour.

I found a post online that shows how to determine how colour an image actually is.

Computing image “colorfulness” with OpenCV and Python

Code

def image_colorfulness(image):
    # split the image into its respective RGB components
    (B, G, R) = cv2.split(image.astype("float"))

    # compute rg = R - G
    rg = np.absolute(R - G)

    # compute yb = 0.5 * (R + G) - B
    yb = np.absolute(0.5 * (R + G) - B)

    # compute the mean and standard deviation of both `rg` and `yb`
    (rbMean, rbStd) = (np.mean(rg), np.std(rg))
    (ybMean, ybStd) = (np.mean(yb), np.std(yb))

    # combine the mean and standard deviations
    stdRoot = np.sqrt((rbStd ** 2) + (ybStd ** 2))
    meanRoot = np.sqrt((rbMean ** 2) + (ybMean ** 2))

    # derive the "colorfulness" metric and return it
    return stdRoot + (0.3 * meanRoot)

PS:

B,G,R = image[...,0],image[...,1],image[...,2]

seems to be 20X faster than

(B, G, R) = cv2.split(image.astype("float"))

For my application the threshold value seems to be 24.00 lesser than this I need to enhance the colour for my application to work properly

I used Gimp tool to enhance the colour

image description

Reduce curve for the colour to be more enhanced

image description

How can I enhance colour of an image in a similar manner using OpenCV?