imresize(...'bilinear') and interp2(...'linear') return different results
Show older comments
x = [0 0 1 1;...
0 0 1 1;...
0 0 0 0;...
0 0 0 0];
imresize(x, [2 2], 'bilinear');
interp2(x, 1.5:2:3.5, (1.5:2:3.5)', 'linear');
I would expect imresize and interp2 to return the same answer above. They do not, however:
>> imresize(x, [2 2], 'bilinear')
ans =
0.1094 0.7656
0.0156 0.1094
>> interp2(x, 1.5:2:3.5, (1.5:2:3.5)', 'linear')
ans =
0 1
0 0
My assumption is that imresize does not adhere to the common definition of bilinear scaling (a linear weighted sum of the immediate 2 neighours in each dimension). Perhaps it is using the (functionally more sensible, but terminology-wise problematic) definition used by ImageMagick, where a triangular function is used as a continouus prototype, meaning that when used for large scale downsampling, more than 4 input samples are used to form one output sample?
https://en.wikipedia.org/wiki/Bilinear_interpolation
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!