Skip to content

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

@littletomatodonkey

Description

@littletomatodonkey

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions