function win = clamp(win,size)
%% win = [rmin,rmax,cmin,cmax]

rmin = max(min(win(1),size(1)),1);
rmax = max(min(win(2),size(1)),1);
cmin = max(min(win(3),size(2)),1);
cmax = max(min(win(4),size(2)),1);

win = [rmin, rmax, cmin, cmax];
