// usage : ImageJ -macro tlrb.txt R[I,R]/ {start increment} {T L R B} {LOG} A=split(getArgument," ,"); C=A.length-1; if (C>=0 && C<=7) { if (C%4>=2) s_i=" starting="+A[1]+" increment="+A[2]; else s_i=""; run("Image Sequence...","open=["+A[0]+"]"+s_i+" sort use"); if (C%2==1) w_f="window and file"; else w_f="window"; W=getWidth; H=getHeight; print(W,H); if (C%2==1) File.append(W+"\t"+H,A[C]); if (C>=4) { c=C-C%2; T=0+A[c-3]; L=0+A[c-2]; R=0+A[c-1]; B=0+A[c]; x=L; w=W-x-R; y=T; h=B+1-y; if (x>=0 && w>=0 && x+w<=W && y>=0 && h>=0 && y+h<=H) makeRectangle(x,y,w,h); } else { T=0; L=0; R=0; B=H-1; } print(T,L,R,B); if (C%2==1) File.append(T+"\t"+L+"\t"+R+"\t"+B,A[C]); setTool("rectangle"); while (true) { setOption("DisablePopupMenu",true); f=4; while (f&4!=0) getCursorLoc(x,y,z,f); while (f&4==0) getCursorLoc(x,y,z,f); setOption("DisablePopupMenu",false); getSelectionBounds(x,y,w,h); T=y; L=x; R=W-x-w; B=y+h-1; if (getBoolean("Top margin = "+T+"\n"+ "Left margin = "+L+"\n"+ "Right margin = "+R+"\n"+ "Bottom position = "+B+"\n \n"+ "record on Log "+w_f+" ?")) { print(T,L,R,B); if (C%2==1) File.append(T+"\t"+L+"\t"+R+"\t"+B,A[C]); } } }