使用双线性插值进行图像下采样和上采样
我试图了解如何使用双线性插值对我拥有的 2D 图像进行上采样和下采样。现在我知道双线性插值如何使用 2x2 邻域值使用权重对这个 2x2 区域内的数据点进行插值。但我不知道的是,下面会问。我的目标和具体查询是 -
1.首先,我有一个值的 2D 图像(大小 MxN)。该图像的宽度(M)和高度(N)不是固定的,而是会根据情况而变化。需要使用双线性插值将该 2D 图像下采样到大小为 PxQ 的网格(P 和 Q 将配置为输入参数),例如假设 PxQ 为 8x8。假设输入 2D 数组图像的大小为 200x100。即 200 列,100 行。
现在,在使用此 200x100 图像的双线性插值执行下采样时,我应该首先获得大小为 100x50 的下采样图像(使用双线性插值在两个维度上下采样 2)吗?然后是 50x25 图像(再次在两个维度上按 2 进行下采样),然后是 25x12 图像,然后是 12x12(这次仅沿行进行线性(不是双线性!)插值进行下采样,最后删除一些像素以获得 8x8 。 任何指向精确算法或实现此目的的不同方法的指针都将受到赞赏。
2.上述问题提出了另一个问题 - 如何通过非整数比例因子使用双线性插值进行下采样,例如如何从 8x8 图像阵列变为 6x2 图像,其中两个维度的重采样/比例因子都不是整数。
3.然后,当我获得 8x8 大小的图像时,我需要通过双线性插值将其上采样到与我开始时相同的原始大小 - MxN。如果我需要从 8x8 变为 20x20。它如何在一行中的点之间进行插值,以及如何通过某种方式插值整行。同样,在非整数比例因子的情况下,用于上采样的双线性插值将如何发生。准确的步骤。
最后,我需要在 C 中实现这一点。
我尝试通过不同的示例来可视化这些特定问题,但没有清楚地了解在下采样和上采样时双线性插值如何发生。我的桌子上只有大量带有“点和交叉”图片的纸张,但仍然没有明确的解决方案!
任何详细的阅读材料,书籍都值得赞赏。
I am trying to understand how exactly the upsampling and downsampling of a 2D image I have, would happen using Bilinear interpolation. Now I am aware of how bilinear interpolation works using a 2x2 neighbourhood values to interpolate the data point inside this 2x2 area using weights. But what I am not aware of, is asked below. My objectives and specific queries are -
1.To start with I have a 2D image of values(size MxN). The width(M) and height(N) of this image is not fixed, but will change from case to case. This 2D image needs to be down-sampled using bilinear interpolation to a grid of size PxQ (P and Q are to be configured as input parameters) e.g. lets take PxQ is 8x8. And assume input 2D array image is of size 200x100. i.e 200 columns, 100 rows.
Now how while performing downsampling using bilinear interpolation of this 200x100 image, should I first obtain a downsampled image of size 100x50 (downsampling by 2 in both dimensions using bilinear interpolation); then a 50x25 image(again by doing downsampling by 2 in both dimensions), then a 25x12 image, then a 12x12(this time doing downsampling by linear(not bilinear!) interpolation only along the rows, and finally drop some pixels to get 8x8.
Any pointers to exact algorithm or different ways to achieve this, are appreciated.
2.Above question raises another one - how to downsample using bilinear interpolation by a non-integer scale factor, e.g. how to go from a say 8x8 image array to a 6x2 image wherein resampling/scaling factors in both dimensions are not integers.
3.Then when I get a 8x8 sized image I need to upsample it by bilinear interpolation to the same original size I started with- MxN. If I need to go from 8x8 to say 20x20. How would it interpolate in between points in a row and would it interpolate a full row by some means. Again in case of non-integer scale factors how would bilinear interpolation for upsampling happen. Exact steps.
And finally I need to implement this in C.
I tried visualizing these particular questions by taking different examples, but not got a clear picture of how this bilinear interpolation would happen while downsampling and upsampling. All I have is plenty of paper sheets having'dots and crossed' pictures on my desk, but still no clear solution!
Any detailed reading material, books appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论