当前位置:网站首页>Review: image saturation calculation formula and image signal-to-noise (PSNR) ratio calculation formula
Review: image saturation calculation formula and image signal-to-noise (PSNR) ratio calculation formula
2022-08-02 06:11:00 【Ice Dew Coke】
复盘:Image saturation calculation formula and image signal noise(PSNR)ratio calculation formula
提示:系列被面试官问的问题,我自己当时不会,所以下来自己复盘一下,认真学习和总结,以应对未来更多的可能性
关于互联网大厂的笔试面试,都是需要细心准备的
(1)自己的科研经历,科研内容,学习的相关领域知识,要熟悉熟透了
(2)自己的实习经历,做了什么内容,学习的领域知识,要熟悉熟透了
(3)除了科研,实习之外,平时自己关注的前沿知识,也不要落下,仔细了解,面试官很在乎你是否喜欢追进新科技,跟进创新概念和技术
(4)准备数据结构与算法,有笔试的大厂,第一关就是手撕代码做算法题
面试中,实际上,你准备数据结构与算法时以备不时之需,有足够的信心面对面试官可能问的算法题,很多情况下你的科研经历和实习经历足够跟面试官聊了,就不需要考你算法了.但很多大厂就会面试问你算法题,因此不论为了笔试面试,数据结构与算法必须熟悉熟透了
秋招提前批好多大厂不考笔试,直接面试,能否免笔试去面试,那就看你简历实力有多强了.
基础知识:
【1】SSIM公式:Structural similarity calculation principle,基于SSIMimage quality evaluation
【2】复盘:图像有哪些基本属性?关于图像的知识你知道哪些?图像的参数有哪些
面试官:Do you know how to calculate the saturation of an image?
Saturation calculation formula:
Ω=number of double bonds+Three keys×2+环数
饱和度可定义为彩度除以明度,与彩度同样表征彩色偏离同亮度灰色的程度.
But because it and chroma determine the same effect in the human eye,
所以才会出现视彩度与饱和度为同一概念的情况.
It can be understood that although the saturation is the same as the saturation in the human eye,
But it actually contains a unit with a higher chroma(饱和度=彩度÷明度).
The difference between high saturation and low saturation:
1、The difference in color brilliance
饱和度越高,The brighter the color;
饱和度偏低,The overall color of the photo is off-white.
2、The difference between oversaturation and undersaturation
Too high saturation will make the overall color of the picture uneven,Gives a distorted visual experience;
If the saturation is low,It is also easy to cause a feeling of opacity to the overall effect of the photo.
There is no calculation formula,就是饱和度SAdjust this dimension!
Check out the articles below
【2】复盘:图像有哪些基本属性?关于图像的知识你知道哪些?图像的参数有哪些
图像饱和度是指图像色彩的纯洁性程度,也称为颜色的鲜艳程度,是“色彩三属性”之一.
我们经常听到Light red has no dark red color red,这种感受就是图像色彩属性的人类最直接感觉.
Saturation depends on the colorContains color components and decolorizing components的比例,
其中含色成分越大,那么饱和度就越大,
同理,如果消色成分越大,必然饱和度越小.
颜色有RGB,HSV,HLS等多种色彩属性模式,
本次主要比较几种不同方法的颜色饱和度调整效果.
def hsv(cv2_img, S, L, V, MAX):
""" HSV 调整 """
cv2_img = cv2_img.astype(np.float32)
cv2_img = cv2_img / 255.0
HSV = cv2.cvtColor(cv2_img, cv2.COLOR_BGR2HSV)
HSV2 = np.copy(HSV)
HSV2[:, :, 1] = (1.0 + V / float(MAX)) * HSV2[:, :, 1] ## 明度
HSV2[:, :, 1][HSV2[:, :, 1] > 1] = 1
HSV2[:, :, 2] = (1.0 + S / float(MAX)) * HSV2[:, :, 2] ### 饱和度
HSV2[:, :, 2][HSV2[:, :, 2] > 1] = 1
adjImg = cv2.cvtColor(HSV2, cv2.COLOR_HSV2BGR)
adjImg = adjImg * 255.0
adjImg = adjImg.astype(np.uint8)
del cv2_img, HSV, HSV2
return adjImg
def hsl(cv2_img, S, L, V, MAX):
""" HSL 饱和度调整 """
cv2_img = cv2_img.astype(np.float32)
cv2_img = cv2_img / 255.0
HLS = cv2.cvtColor(cv2_img, cv2.COLOR_BGR2HLS)
HLS2 = np.copy(HLS)
HLS2[:, :, 1] = (1.0 + L / float(MAX)) * HLS2[:, :, 1] ## 明度
HLS2[:, :, 1][HLS2[:, :, 1] > 1] = 1
HLS2[:, :, 2] = (1.0 + S / float(MAX)) * HLS2[:, :, 2] ### 饱和度
HLS2[:, :, 2][HLS2[:, :, 2] > 1] = 1
adjImg = cv2.cvtColor(HLS2, cv2.COLOR_HLS2BGR)
adjImg = adjImg * 255.0
adjImg = adjImg.astype(np.uint8)
del cv2_img, HLS, HLS2
return adjImg
def saturationAdjust(cv2_img):
#### 图像颜色饱和度
cv2.namedWindow("SatuAdj", 0)
cv2.createTrackbar('S', 'SatuAdj', 10, 100, callback)
cv2.createTrackbar('V', 'SatuAdj', 10, 100, callback)
cv2.createTrackbar('L', 'SatuAdj', 10, 100, callback)
cv2.createTrackbar('I', 'SatuAdj', -100, 100, callback)
cv2.createTrackbar('Max', 'SatuAdj', 60, 360, callback)
####视图区域
input_img = cv2_img.copy()
while True:
S, V, L, I, MAX = callback(0)
hsv_img = hsv(input_img.copy(), S, L, V, MAX)
hsl_img = hsl(input_img.copy(), S, L, V, MAX)
rgb_img = rgb(input_img.copy(), I)
mat_img = np.hstack((input_img, hsv_img, hsl_img, rgb_img))
text = f"Max:{
MAX},S:{
S}, V:{
V}, L:{
L}"
cv2.putText(mat_img, text, (10, 40), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 0), 1)
cv2.imshow("SatuAdj", mat_img)
cv2.waitKey(1)
HSV图像中的S就是饱和度,改变S值,Saturation can be adjusted
原始图像:
改变效果1
改变效果2
改变效果3
面试官:You know the image signal-to-noise ratio(PSNR)Calculate the formula?
Peak signal-to-noise ratio (PSNR)
Image peak-to-signal ratio.
(1)MSE (Mean Square Error) 描述Original and processed images的均方误差
(2)PSNR的定义是
其中MAXIRepresents the maximum value of a color image,
8Bit sampling points can be obtained255.
对于彩色图片,只需要在计算MSE时,三个通道的MSE求均值即可.
Remember to convert the image to float类型后再进行运算,否则,uint8The result of the calculation has no negative numbers
def get_psnr(im1, im2):
im1 = np.asarray(im1, dtype=np.float64)
im2 = np.asarray(im2, dtype=np.float64)
mse = np.mean(np.square(im1 - im2))
return 10. * np.log10(np.square(255.) / mse)
Question: PSNR 仍然是基于MSE的评价,与直接用MSE有和区别?
A:
Question: PSNRThe original evaluation is the loss of image quality caused by image compression,MSE越低,PSNR越高,It means that the image compression loss is lower,So for image enhancement,是否PSNRThe higher it is, the better the enhancement effect is?
A: for image enhancement,无论是否有ground truth,都是PSNR越高效果越好.
不过许多实验结果都显示,PSNR 的分数无法和人眼看到的视觉品质完全一致,
有可能 PSNR 较高者看起来反而比 PSNR 较低者差.
这是因为人眼的视觉对于误差的敏感度并不是绝对的,
其感知结果会受到许多因素的影响而产生变化(例如:人眼对空间频率较低的对比差异敏感度较高,人眼对亮度对比差异的敏感度较色度高,人眼对一个区域的感知结果会受到其周围邻近区域的影响).
由于PSNR计算量低,已于实现,使用广泛,但是PSNRIt is not easy to agree with the subjective judgment of human vision.
SSIM更好一些.也就是说PSNRIf the score is good,可以用, Don't worry about bad grades.
SSIM是啥?我之前写过:
【1】SSIM公式:Structural similarity calculation principle,基于SSIMimage quality evaluation
总结
提示:重要经验:
1)Image saturation is just thatHSV中S,hue是色相:Color looks,红橙黄绿青蓝紫;S就是饱和度,调整它,V即Value亮度
2)图像信噪比,is the signal-to-noise ratio of the two images compared,maxi方/MSE的对数
3)笔试求AC,可以不考虑空间复杂度,但是面试既要考虑时间复杂度最优,也要考虑空间复杂度最优.
边栏推荐
猜你喜欢
随机推荐
MySQL安装教程
mysql实现按照自定义(指定顺序)排序
Matlab学习第二天
MYSQL 唯一约束
golang's time package: methods for time interval formatting and output of timestamp formats such as seconds, milliseconds, and nanoseconds
Navicat cannot connect to mysql super detailed processing method
简道云-灵活易用的应用搭建平台
The original question on the two sides of the automatic test of the byte beating (arranged according to the recording) is real and effective 26
Grid布局介绍
牛客-TOP101-BM41
el-input can only input integers (including positive numbers, negative numbers, 0) or only integers (including positive numbers, negative numbers, 0) and decimals
认识消防报警联网中CAN光纤转换器的光纤接口和配套光纤线缆
Mysql存储json格式数据
apifox介绍及使用(1)。
MySQL String Concatenation - Various String Concatenation Practical Cases
AMQP协议详解
pg数据库报错问题,有懂的吗
【语义分割】FCN
MySQL 灵魂 16 问,你能撑到第几问?
navicat新建数据库