Resize in MATLAB with various filters

I have an image. I want to resize it to double the original size, filling the new pixels with interpolation. I need to specify what type of interpolation I want to use.

I see the imresize function, which has an option for the "method". The problem is that there are only 3 options: the closest, bilinear, bicubic. Bilinear and bicubic middle / middle methods, but is there any way to set the size / weight of the neighborhood?

The main problem is that I need to do this using the median interpolation method instead of the average. How can I say to use this method?

+2
source share
3 answers

The way IMRESIZE implements interpolation is the calculation for each pixel in the output image (reverse mapping), the pixel indices in the input image that will be involved in the interpolation, together with the supporting weights.

Proximity and weight are determined by the type of interpolation core used, which, as @Albert points out , can be passed to the IMRESIZE function (the 'Method' property can take a {f,w} array of cells with a kernel function and a kernel width)

These two components will be used to compute a linear combination of input pixels to fill each value of the output pixels. This process is performed for each measurement separately once at a time (vertically, then horizontally).

Now the problem is that you can never get the median value using a linear combination, because the median is a non-linear ordering filter. Therefore, your only option is to write your own implementation ...

+4
source

Amro is right that the average filter cannot be calculated as a weighted response. But MATLAB has a specific function for the median filter: medfilt2 .

+1
source

imresize has a third way of transmitting the interpolation method: "A two-element array of cells defining the interpolation core." See the Matlab documentation for more details.

0
source

Source: https://habr.com/ru/post/1206539/


All Articles