Ask Your Question

cv.imread() pixel-level errors between py2 and py3

asked 2019-01-22 21:37:34 -0500

I'm debugging an image-related program in py2 and py3 environments. The strange point is, the performance in py3 env is always belower than that in py2 env. So I traced back to the very beginning,and I found that after the first cv.imread(), there exists pixel-level errors. The two pixels at the same location but in different envs having an difference of 1. .What may be the reason leading to this problem?

opencv in two envs: opencv3 - 3.1.0 - build py36_0 opencv - 2.4.11 -build nppy27_0

Besides, though searched, I'm still confused at the relationship of opencv3, opencv 3.x, and opencv 2.x. Can the version of opencv be the reason leading to this small difference?

edit retag flag offensive close merge delete


Most likely you are trying to open .jpg image?

dkurt gravatar imagedkurt ( 2019-01-23 01:25:43 -0500 )edit

@dkurt, sorry for the late reply, yes I'm trying to open an .jpeg file. Any clues?

LCAR979 gravatar imageLCAR979 ( 2019-02-17 20:14:02 -0500 )edit

I see. I didn't realize that it may be related to file formats and decompression process. Thanks for your insightful clues.

LCAR979 gravatar imageLCAR979 ( 2019-02-18 20:47:21 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2019-02-18 01:10:39 -0500

dkurt gravatar image

The difference not in python versions but in OpenCV versions because of different version of 3rdparty libjpeg (a library which is used by OpenCV to read jpeg images). JPEG format doesn't guarantee cross platform and cross version exactness. That is why OpenCV uses .png images for accuracy tests, in example.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-01-22 21:37:34 -0500

Seen: 91 times

Last updated: Jan 22 '19