Search code examples
c++opencvpngjpeg

Vec3b: Max value for r/g/b color is 254 instead of 255


I have one strange question, since I haven't seen any similar problem yet.

I made a pictures in Adobe Illustrator (both jpg and png) 300x100, with 100x100 boxes for each red(255,0,0), green(0,255,0), blue(0,0,255) part. When I try to reach color codes, from JPG file, for any of colors it shows 254, instead of 255 as it's made. When I try the same with PNG file, it shows 255 as it should be.

Any ideas why it's happening?

P.S I did triple check on color codes while making photos, so that's not an issue


Solution

  • JPEG compression is usually lossy, not lossless. The JPEG-LS and JPEG2000 codecs being the exceptions. Losing detail is expected.

    PNG however is always lossless.