2014-12-23 60 views
2

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

想要在imwarp函数契约中使用它,即包含imref2d类来指定图像世界维度。

enter image description here

我想拼切图像具有像素,对齐,以它自己的利润,因此,相对转移到原始像素。但像素的比例应该是相同的。

回答

2

我不知道任何匹配的图像处理功能,所以我会手工进行:

%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{:}) 
+0

顺便说一句,我不明白单元阵列的用法,因为'I {:}'被评估为三个答案。它如何被用作函数参数? –

+0

是的,它与'ngrid(I {1},I {2},I {3})'相同。欲了解更多详情,请访问:http://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html?s_tid=doc_12b – Daniel