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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With