nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
25.99k stars 7.67k forks source link

The Jpeg image is decoded incorrectly. #1503

Closed evilrace closed 1 year ago

evilrace commented 1 year ago

Describe the bug A clear and concise description of what the bug is. I load a image using stb_image.h library. but the values of image are different with values loaded by other libraries(opencv, window paint app) In detail, the value at position (47,27,2 h,w,c) of image is 128, but stb image read this as 130. the difference points are displayed as below. this shows difference between original image loaded by opencv and stb image scaled up by 255 times image

To Reproduce Steps to reproduce the behavior:

  1. read the image below
  2. compare the values this with a image loaded by other image library dog_416x416

Expected behavior A clear and concise description of what you expected to happen.

loaded values are different.

Screenshots If applicable, add screenshots to help explain your problem.

nothings commented 1 year ago

This is not a bug.

JPEG images are a lossy format which do not exactly reproduce the original compressed image. The exact nature of that inexact reproduction is not defined by the JPEG specification; there is no standard correct way to decode a given JPEG. Every decoder is potentially different, and producing different values from other decoders is the execpted behavior.