OpenCV equivalent to PIL.Image.ANTIALIAS [closed]

asked 2018-05-10 03:51:29 -0600

jczaja gravatar image

Hi,

I want to mimic behavior of PIL.Image.resize(...,interpolation=PIL.Image.ANTIALIAS). What I would like to expect, is to have matching pixel vales (~99.9% exact match should be fine) . How can I do this with OpenCV ? I tried Opencv resize with available interpolation methods (including LANCZOS4) , but result does differ from the one I got from PIL.

Why I'm doing this? Well I 'm developing machine learning program in C that is using (infer) pre-trained model (done in Python+PIL with PIL.Image.ANTIALIAS). Even small differences in preprocessing of images has an impact on how machine learning model behave. So either I find a way to achieve same resize behavior in OpenCV as used in PIL.Image.ANTIALIAS or how to use PIL in C .

Thanks in advance for answering my question

Please advice

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2018-05-10 03:54:02.483915

Comments

"but result does differ from the one I got from PIL. " -- not the same library, different purpose.

berak gravatar imageberak ( 2018-05-10 03:53:50 -0600 )edit

and no, we cannot help you with any problem using PIL.

berak gravatar imageberak ( 2018-05-10 03:54:39 -0600 )edit

"Even small differences in preprocessing of images has an impact on how machine learning model behave."

In my small knowledge of deep learning topic, small deviation in input can produce different output value (e.g. different classification probability) but should not change the output (e.g. classification class). In other words, the great thing of deep learning is that they can generalize very well to the type of problem to solve. If the resize method produces a slightly different result, it should not matter since you should have trained a network able to cope with very different inputs.

Eduardo gravatar imageEduardo ( 2018-05-10 08:43:06 -0600 )edit