Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB imresize with a custom interpolation kernel

how can I use my function as an interpolation method for imresize function in MATLAB?

I read MATLAB's help about the way to use a custom function for interpolation method, but there was not any clear example. and I tried to write a code for ma

like image 286
user1033629 Avatar asked Jan 19 '23 08:01

user1033629


1 Answers

The imresize command will by default use the bicubic method. You can alternatively specify one of several other built-in interpolation methods or kernels, such as

imNewSize = imresize(imOldSize, sizeFactor, 'box')

for a box-shaped kernel. If you want to specify your own bespoke kernel, you can pass that in as a function handle, along with a kernel width, in a cell array. For example, to implement the box-shaped kernel yourself (without using the built-in one) with a kernel width of 4, try:

boxKernel = @(x)(-0.5 <= x) & (x < 0.5);
imNewSize = imresize(imOldSize, sizeFactor, {boxKernel, 4});

If you type edit imresize and look inside the function, from about line 893 you can find implementations of the other built-in kernels, which may give you some hints about how you can implement your own.

like image 196
Sam Roberts Avatar answered Jan 31 '23 21:01

Sam Roberts