Igb
Igb

Reputation: 246

Slight differences in pixel values between OpenCV and Matlab

I am trying to port some old matlab code to python. I chose OpenCV as I am familiar with the library. Despite that, I found results differ a bit (this program seems very sensible to small changes in texture), and I found pixel values are sightly different even with just reading the image from disk (I thought It could be some antialiasing or odd behavior when reecaling, but its there even before modifying anything)

I am aware of the different color order (RGB in matlab by default, BGR on OpenCV), but still pixel values are sometimes off by +-2 units (on 8-bit per color images). See for example in the following screencap, second pixel is 5-14-9 (RGB) when in matlab its 5-14-11. First pixel is exactly the same value.

OpenCV/Matlab differences

I can't think of any way to check the EXACT transformation/rounding that matlab is performing, or why this is different in the first place. Any Ideas on this matter?

Upvotes: 0

Views: 263

Answers (1)

David
David

Reputation: 69

Are you sure that you are looking at the correct pixel? Matlab and Python differ in indexing, in Matlab the first index is 1, and in Python the first index is 0.

My guess is that you should be comparing the Matlab pixel [2,1] with the Python pixel value at index 0, which is 5-14-11 like the one in Matlab.

Upvotes: 4

Related Questions