使用不同的过滤器在 MATLAB 中调整大小 [英] Resizing in MATLAB w/ different filters

查看:18
本文介绍了使用不同的过滤器在 MATLAB 中调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张图片.我想将其调整为原始大小的两倍,通过插值填充新像素.我需要指定我想使用哪种类型的插值.

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.

我看到了 imresize 函数,它有一个方法"选项.问题是,只有 3 个选项:最近、双线性、双三次.双线性和双三次是平均/均值方法,但有没有办法设置邻域大小/权重?

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?

推荐答案

IMRESIZE 实现插值的方式是通过计算输出图像中的每个像素(逆映射),输入图像中像素的索引参与插值,以及贡献权重.

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.

邻域和权重由所使用的插值核的类型决定,如@Albert 指出,可以传递给 IMRESIZE 函数('Method' 属性可以接受{f,w}一个带有核函数和核宽度的元胞数组)

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

这篇关于使用不同的过滤器在 MATLAB 中调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆