[英]image interpolation
嗨,在我的项目中,我想在这些图像中提供一些静止图像,我应该将混洗图像作为输入,但是输出将像连续图像一样,它可以通过使用插值方法比较最近的邻居,我如何实现plz告诉我.i有一些代码告诉我它如何工作。
public InterpolationMethod method = InterpolationMethod.Bilinear;
public int newWidth = 0;
public int newHeight = 0;
try {
this.newWidth = Math.Max(1, Math.Min(5000, int.Parse(widthBox.Text)));
this.newHeight = Math.Max(1, Math.Min(5000, int.Parse(heightBox.Text)));
this.method = (methodCombo.SelectedIndex == 0)
? InterpolationMethod.NearestNeighbor
: (methodCombo.SelectedIndex == 1)
? InterpolationMethod.Bilinear
: InterpolationMethod.Bicubic;
this.DialogResult = DialogResult.OK;
this.Close();
}
catch (Exception)
{
MessageBox.Show(this, "Incorrect values are entered", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
从最近的邻居插值开始-这是最简单的。 基本上,这种方法是这样的:
(row, col)
,计算出旧图像中的相应位置(row_o, col_o)
。 例如,如果旧图像的大小是原来的一半,则row_o = row/2
而col_o = col/2
。 注意,由于所有像素位置都是整数,因此会涉及一些舍入。 对于最近的邻居插值,这是必不可少的,您无法避免。 (row_o, col_o)
的像素值 row, col)
的新图像 一旦解决了这个问题,其他方法应该更有意义。
扫描线遍历:
for (i=0; i < image.height; ++i)
for (j=0; j < image.width; ++j)
{
// Do stuff here
}
看起来像什么:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.