python - JPEG压缩期间颜色的微小变化

标签 python opencv colors python-imaging-library jpeg

看起来Ubuntu下的默认库在压缩过程中会稍微改变颜色。我尝试设置质量和抽样,但没有看到改进,有人质疑过类似问题吗?

二次抽样= 0,质量= 100

#CORRECT COLORS FROM NPARRAY
cv2.imshow("Object cam:{}".format(self.camera_id), self.out)

print(self.out.item(1,1,0)) # B 
print(self.out.item(1,1,1)) # G
print(self.out.item(1,1,2)) # R

self.out=cv2.cvtColor(self.out,  cv2.COLOR_BGR2RGB)

#from PIL import Image
im = Image.fromarray(self.out)
r, g, b = im.getpixel((1, 1))
## just printing pixel and they are matching  
print(r, g, b) 
## WRONG COLORS
im.save(self.out_ramdisk_img,format='JPEG', subsampling=0, quality=100)

enter image description here

JPEG图像的颜色应与imshow中的颜色相同,但略带紫色。

最佳答案

这是JPEG压缩的自然结果。 JPEG使用浮点算法来计算整数像素值。这发生在JPEG压缩的多个阶段。因此,期望小的像素值变化。

当您进行全面的颜色更改时,它们通常是结果输入颜色值,该值超出YCbCr颜色空间的色域。这样的值被限制。

关于python - JPEG压缩期间颜色的微小变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56745070/

相关文章:

c++ - 在维基百科中使用哪种颜色渐变为曼德布罗着色?

python - 测试另一个函数的所有数字 1 到 1000 的函数

python - 从当前时间获取小时

python - 如何使用 matplotlib 创建相等数量的主要和次要 y 轴刻度?

C# 相当于使用 python 切片操作旋转列表

c++ - 变形图像和 Homography opencv 矩阵的问题

python - 如何过滤蒙版中不需要的点

python - cv.smooth() 去哪儿了?我在 cv2 中找不到等效项

javascript - 保存后台设置的简单 cookie

google-maps - 谷歌用其他颜色映射 v3 默认标记路径