Reputation: 4285
Is there a built-in function in Octave to crop a specific region from an image? I have installed the image processing package but I don't find a function like imcrop
or something like that.
Upvotes: 1
Views: 5365
Reputation: 19037
The imcrop
function exists now:
imcrop(Image, [x y 20 20])
would crop an image of 20x20
pixels starting from the (x,y)
coordinate.
Upvotes: 2
Reputation: 3255
How about if your image (which is a matrix in Octave) is I
, and you want to crop from x,y
a block of size w,l
, then resize(circshift(I,-x,-y), w, l)
ought to do it. Basically, shift the matrix so that x,y
is now at 1,1
, and just cut off the rest of the matrix past w,l
.
EDIT: Actually, that was before I learned about matrix indexing. Instead, this is what you want:
Croppedimage = Image(y:y+l-1, x:x+w-1)
Upvotes: 1