Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
546 views
in Technique[技术] by (71.8m points)

image - Resizing in MATLAB w/ different filters

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...