2

Is it possible to cut part of an image in Matlab, so that the cut lines were in fractional pixel position?

Would like to have it in imwarp function contract, i.e. including imref2d class to designate image world dimensions.

enter image description here

I would like cutted image to have pixels, aligned to it's own margins and, therefore, shifted relatively to original pixels. But the scale of the pixels should be the same.

Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385

1 Answers1

2

I don't know any matching image processing function, so I would do it manually:

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

This code is for 2D-images (grayscale), for coloured images:

%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{:})
Daniel
  • 36,610
  • 3
  • 36
  • 69
  • BTW I don't understand usage of cell arrays, since `I{:}` is evaluated to three answers. How can it be used as function argument? – Suzan Cioc Dec 24 '14 at 02:30
  • Yes, it`s the same as `ngrid(I{1},I{2},I{3})`. For more details: http://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html?s_tid=doc_12b – Daniel Dec 24 '14 at 10:19