Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems that cv2.resize and PIL.resize results are different #4445

Closed
littletomatodonkey opened this issue Feb 22, 2020 · 1 comment
Closed

Comments

@littletomatodonkey
Copy link

littletomatodonkey commented Feb 22, 2020

Also see the title, I did the test following the code.

import cv2
from PIL import Image
import matplotlib.pyplot as plt
img = cv2.imread("./ILSVRC2012/ILSVRC2012_val_00000001.JPEG")
img = img[:, :, ::-1]
cv_img = cv2.resize( img, (224,224), interpolation=cv2.INTER_LINEAR).astype( np.float32 )
pil_image = Image.fromarray( img )
pil_image = pil_image.resize((224, 224), Image.BILINEAR)
pil_image = np.array(pil_image).astype( np.float32 )
print( cv_img.dtype, pil_image.dtype )
diff = np.sum( np.abs(cv_img-pil_image) )
print( diff )

The diff s 397057.0 under the same mode. The PIL version is 6.2.1, opencv version is 4.1.1, so is it always different here?

@radarhere
Copy link
Member

radarhere commented Feb 23, 2020

Is the discussion in #2718 helpful?

There is also #4320 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants