//Stack Combiner macro "Stack Combiner"{ call("java.lang.System.gc"); //saveSettings(); currtit=getTitle(); nim=nImages; if (nim<2) exit("Not enough images are open"); else { imagetitles=newArray(nim); for (i=1; i<=nim; i++) { selectImage(i); imagetitles[i-1]=getTitle; } } Dialog.create("Stack Combiner"); Dialog.addChoice("First Stack: ", imagetitles, currtit); next=imagetitles[0]; if(next==currtit) next=imagetitles[1]; Dialog.addChoice("Second Stack: ", imagetitles, next); Dialog.addChoice("Direction of combo: ", newArray("Right","Bottom"), "Right"); Dialog.addMessage("You can scroll wheel click during alignment to change combination direction"); Dialog.addChoice("Paste Mode: ",newArray("Copy","Max","Transparent-zero","Blend"),"Transparent-zero"); Dialog.addCheckbox("Prioritize first stack?",true); Dialog.addCheckbox("Manual offset?",false); Dialog.addNumber("x offset:",0); Dialog.addNumber("y offset:",0); Dialog.show(); left=Dialog.getChoice(); right=Dialog.getChoice(); direction=Dialog.getChoice(); pmode=Dialog.getChoice(); pfs=Dialog.getCheckbox(); manual=Dialog.getCheckbox(); x=Dialog.getNumber(); y=Dialog.getNumber(); comp=false; selectWindow(left); selectWindow(left); getDimensions(wl, hl, chsl, slsl, frmsl); Stack.getPosition(ch, sll, frl); if(manual && direction=="Right") x=wl-x; if(manual && direction=="Bottom")y=hl-y; selectWindow(right); getDimensions(wr,hr,chsr,slsr,frmsr); if(chsr>1) Stack.setChannel(ch); Stack.getPosition(chr, slr, frr); bitsr=bitDepth(); run("Select All"); run("Copy"); selectWindow(left); if(chsl!=chsr) exit("Must have same number of channels"); if(bitsr!=bitDepth()) exit("Files have different bit depths, no can do."); if(frr!=frl){if(!getBoolean("Frames don't match, but can't match frames yet, assume both are at 1?")) exit("Ok cancelled");} frms=minOf(frmsl,frmsr); run("Select None"); if(slsl==1) run("Duplicate...", "title=temp duplicate"); else run("Duplicate...", "title=temp"); if(chsl>1) {Stack.setChannel(ch); comp=true;} if(!manual){ flags=-1; leftButton=16; centerButton=8; setPasteMode("Max"); snapshot(); isok=true; rtsd=0; if(direction=="Bottom") rtsd=false; while(isok){ while (flags&leftButton!=0) {getCursorLoc(xc, yc, zc, flags); wait(100); } getCursorLoc(x, y, z, flags); while (flags&leftButton==0) { checkchange=false; while (flags¢erButton!=0) {getCursorLoc(xc, yc, zc, flags); wait(100); checkchange=true;} if(checkchange){rtsd++; if(rtsd==4)rtsd=0;} reset(); //snapshot(); getCursorLoc(x, y, z, flags); maxxy=maxOf(x,y); //if(maxxy==x) makeRectangle(x,0,w,h); //else makeRectangle(0,y,w,h); if(rtsd==0) {y-=0.5*hr;} else if(rtsd==2) {x+=-0.5*wr; } else if(rtsd==1){y-=hr;} makeRectangle(x,y,wr,hr); run("Paste"); wait(100); } isok=!getBoolean("x:"+x+" y:"+y+" sound ok?"); } } close(); //offset=maxxy; //if(maxxy==y) bottom=true; //else bottom=false; setPasteMode(pmode); mingo=newArray(chsl); maxgo=newArray(chsl); getMinAndMax(mingo[0],maxgo[0]); if(comp) { colors=newArray(chsl); for(k=0;k-1){ adder="01"; if(ioaj0 && nowsl<=slsl) go=true; wid=wl; hei=hl; stx=xl; sty=yl; } else { selectWindow(right); nowsl=(i+(slr-starter)); if(nowsl>0 && nowsl<=slsr) go=true; wid=wr; hei=hr; //if(bottom) {stx=0; sty=offset;} //else {stx=offset; sty=0;} stx=x; sty=y; } if(go){ Stack.setPosition((k+1), nowsl, fr+1); run("Select All"); run("Copy"); selectWindow(newtitle); Stack.setPosition((k+1), (i+1+begfac), fr+1); makeRectangle(stx,sty,wid,hei); run("Paste"); } } } } } selectWindow(left); Stack.setSlice(sll); Stack.setFrame(1); selectWindow(right); Stack.setSlice(slr); Stack.setFrame(1); selectWindow(newtitle); run("Select None"); for(k=0;k