image thumbnail
from Region of interest - GUI by Omry Blum
The GUI panel lets you review a full movie before cropping and saving its images to disk

[mov,cV]=cropvid(app)
function [mov,cV]=cropvid(app)

nFrames=app.V.NumberOfFrames;
try
rect=round(getPosition(app.Rect));
catch
rect=[1 1 app.cV.Width app.cV.Height];
end

axpos=round(get(app.Axes,'position'));
%fgpos=round(get(app.Figure,'position'));
vidHeight=rect(4);
vidWidth=rect(3);

mov(1:nFrames) = struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),'colormap', []); % Preallocate movie structure
disp(rect)
for i = 1 : nFrames
    %mov(i).cdata=app.Mov(i).cdata(fgpos(4)-rect(2)-rect(4):fgpos(4)-rect(2)...
     %  ,rect(1):rect(1)+rect(3),:);
    mov(i).cdata=app.Mov(i).cdata(axpos(4)-rect(2)-rect(4)+2:axpos(4)-rect(2)+1,rect(1):rect(1)+rect(3)-1,:);
end
cV.Height=vidHeight;
cV.Width=vidWidth;
end

Contact us