2014-12-23 57 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