image - 如何在Matlab中用分数像素切割图像?

标签 image matlab image-processing interpolation resampling

是否可以在Matlab中剪切图像的一部分,以便剪切线位于分数像素位置?

想把它放在 imwarp 中函数合约,即包括imref2d类来指定图像世界尺寸。

enter image description here

我希望剪切的图像具有像素,与它自己的边距对齐,因此相对于原始像素移动。但像素的比例应该相同。

最佳答案

我不知道任何匹配的图像处理函数,所以我会手动完成:

%defines the image section you want
I={[2.5:1:5],[3.5:1:5.5]}
%spans a grid
[P{1},P{2}]=ndgrid(I{:})
%interpolates using the grid
IMG2=interpn(IMG,P{:})

此代码适用于 2D 图像(灰度),适用于彩色图像:

%defines the image section you want
I={[2.5:1:5],[3.5:1:5.5]}
%We dont want to interpolate on colour axis, fix it to 1:3 for rgb
I{3}=1:size(IMG,3)
%spans a grid
[P{1},P{2},P{3}]=ndgrid(I{:})
%interpolates using the grid
IMG2=interpn(IMG,P{:})

关于image - 如何在Matlab中用分数像素切割图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27628578/

相关文章:

python - 使用 python 和 PIL 分割图像以计算多个矩形对象的质心和旋转

r - 如何知道R中矩阵或向量的维度?

android - 从文件调整图像大小

c# - 显示图片尺寸

html - 如何在图像下放置 figcaption

matlab - 如何使用向量化代码从 MATLAB 中的两个向量生成所有对?

matlab - 如何检测我运行的是 MATLAB 还是 Octave?

java - 如何在 Java 中压缩 jpeg 图像而不丢失该图像中的任何元数据?

python - matplotlib 补丁可以与函数一起使用吗?

html - 如何用图像填充 div 并仍然响应?