Resizing in MATLAB w/ different filters

让人想犯罪 __ 提交于 2019-12-17 21:31:59

问题


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

I see the imresize function, which has an option for 'method'. The problem is, there are only 3 options: nearest, bilinear, bicubic. Bilinear and bicubic are averaging/mean methods, but is there any way to set the neighborhood size / weighting?

The main problem is, I need to do it with a 'median' interpolation method, instead of mean. How can I tell it to use this method?


回答1:


The way that IMRESIZE implements interpolation is by calculating for each pixel in the output image (inverse mapping), the indices of the pixels in the input image that are going to be involved in the interpolation, along with the contributing weights.

The neighborhood and the weights are determined by the type of the interpolation kernel used, which as @Albert points out, can be passed along to the IMRESIZE function (the 'Method' property can accept {f,w} a cell array with the kernel function and the kernel width)

These two components will be used to compute linear combination of the input pixels involved to fill each value of the output pixels. This process is performed along each dimension separately one-at-a-time (vertically then horizontally).

Now the problem for you is that you can never obtain the median value by using a linear combination, that's because median is a non-linear ordering filter. So your only option is to write your own implementation...




回答2:


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




回答3:


imresize has a third way of passing the interpolation method: "Two-element Cell Array Specifying Interpolation Kernel". You can read more about it in Matlab's documentation.



来源:https://stackoverflow.com/questions/7758078/resizing-in-matlab-w-different-filters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!