I'm not sure exactly how the algorithm works.
In the general case, I'm wondering if I resize an image to a larger size and then resize it down back to the original size, will the image be the same as the original?
I'm not sure exactly how the algorithm works.
In the general case, I'm wondering if I resize an image to a larger size and then resize it down back to the original size, will the image be the same as the original?
It depends on the interpolation type that you use, and the type of the image. For example, NEAREST
and BILINEAR
should give identical results if you use the same method in both directions. BICUBIC
and LANCZOS
may not be as invertible in the general case. None of the methods will be perfectly invertible if you do downsampling first, before upsampling. Most will not be invertible if you use different filters in the two directions. Using BICUBIC
to upsample and NEAREST
to downsample should yield identical results most of the time, since splines guarantee the value at the nodes. It will not work if the locations chosen for the downsampling are off (but that can be fixed with appropriate padding).
If your intention is to use the resize
method without an explicit argument to upsample and then downsample, the result is likely to be invertible in the general case since it will use NEAREST
in both directions.