是否可以在Matlab中剪切图像的一部分,以便剪切线位于分数像素位置?
想把它放在 imwarp
中函数合约,即包括imref2d
类来指定图像世界尺寸。
我希望剪切的图像具有像素,与它自己的边距对齐,因此相对于原始像素移动。但像素的比例应该相同。
最佳答案
我不知道任何匹配的图像处理函数,所以我会手动完成:
%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/