【发布时间】:2019-06-24 23:25:45
【问题描述】:
看起来 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)
JPEG 图像的颜色应该与 imshow 中的颜色相同,但偏紫一点。
【问题讨论】:
-
JPEG 是一种有损压缩。因此它可以稍微改变颜色。但我怀疑一张图片有颜色配置文件,而另一张没有。或者两个版本的颜色配置文件不同。检查一下。
标签: python opencv colors python-imaging-library jpeg