In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces you to OpenCV calculation of image color richness example analysis, the content is very detailed, interested friends can refer to, I hope to help you.
Calculate image color richness
First, we need to have a standard of color richness. Hasler and Süsstrunk's study classified color richness into seven levels.
Not colorful
Slightly colorful
Moderately colorful
Average (Averagely colorful)
Very colorful
Highly colorful
Extremely colorful
Hasler and Süsstrunk asked 20 people to rate 84 images on a scale of 1 to 7. Finally, the survey data analysis, found that the picture color richness has the following calculation formula.
The final C is an indicator of color richness (sigma and miu stand for standard deviation and mean, respectively).
Code import cv2
import numpy as np
def image_colorfulness(image): #Divide the picture into three parts B,G,R (note that R, G, B are vectors instead of scalars) (B, G, R) = cv2.split(image.astype("float")) #rg = R - G rg = np.absolute(R - G) #yb = 0.5 * (R + G) - B yb = np.absolute(0.5 * (R + G) - B) #Calculate the mean and standard deviation of rg and yb (rbMean, rbStd) = (np.mean(rg), np.std(rg)) (ybMean, ybStd) = (np.mean(yb), np.std(yb)) #Calculate the standard deviation and mean of rgyb stdRoot = np.sqrt((rbStd ** 2) + (ybStd ** 2)) meanRoot = np.sqrt((rbMean ** 2) + (ybMean ** 2)) #Return color richness C return stdRoot + (0.3 * meanRoot)
image = cv2.imread ('image path')
print(image_colorfulness(image))
run
#Return image richness value (0-100) About OpenCV calculation image color richness example analysis shared here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.