CombineZ Command Line Operation

CombineZ5.3 the .exe file

At the simplest level this allows you to drag a folder containing a set of pictures that form a stack and drop it on the .exe file.   The stack will be loaded and then CombineZ will start up.   I have put a shortcut to CZ on my desktop and I drop a folder onto that.   It's just a quicker way of getting going.

With the spread of computer controlled microscopes Stephen J Michalczyk has asked if it is possible to have CZ launched by another program which passes folder and file information to it so that stacks can be processed from the slide to the finished image completely automatically.   The answer was no, but with CombineZ 5.3 it has become possible.

here is a simple command line:-

    CombineZ5.exe "C:/My Pictures/Flower" "Do Stack" "C:My Pictures/Result/flower.tif" -q

First there is the name of the program to execute, then the path to a folder containing the pictures to process, then the Macro to use, then the path to the finished picture and the -q switch says quit CZ when finished.

One trap for the unwary is that you must create the folder, 'Result' in this case, which is going to contain the stacked images beforehand. 

If you are a programmer you should be able to understand this example, it's written in C++ but you should be able to convert to any other language quite easily:-

char 
    prog[]="C:/Program Files/Microsoft Visual Studio/MyProjects/Combine/Release/combine.exe",
    prog_arg[]="\"C:/Program Files/Microsoft Visual Studio/MyProjects/Combine/Release/combine.exe\"",
    *args[6];

args[0]=prog_arg;
args[1]="\"C:/Documents and Settings/Owner/Desktop/fly2\"";
args[2]="\"Do Stack\"";
args[3]="\"C:/Documents and Settings/Owner/Desktop/Result/output.tif\"";
args[4]="-r -w -c -q";
args[5]=0;

_spawnv(_P_WAIT,prog,args);

At the start two strings are defined both of them are the path to combine.exe which is my experemental version of CombineZ5.   Not that on the Commandline arguments are seperated by spaces, so something like My Documents would be treated like two parameters.   To prevent this enclose the path in quotes.   In C++ to get a quote included inside a quoted string you use the \" escape sequence.

In this example I have split the arguments into 5 chunks and added a "0" argument at the end these are stored in the args array.

args[0] is just the path to CombineZ.

args[1] is the path to a folder called fly2, in it are the pictures to be stacked, the usual rule applies i.e. they must all be the same size.   Remember not to include any pictures you do not want including in the stack in this folder.

args[2] is the name of the Macro to execute Do Stack in this case.   Remember if you launch CZ edit the macro's and leave CZ the edited macros will be reloaded next time the program starts up.   So if you wish to use the defaults you must restore them from the Macro menu, leave CZ and run the program that generates the command line.

args[3] is the desired path of the finished picture, this is optionjal.

args[4] is a set of switches, they are all optional.

-r causes a set of Rectangles to be exported into a folder called 'rectangles' in the same folder as the original pictures.   These are saved in the .tif format.

-w saves work information when the processing is finished, so that Resume Work will reinstate the stacked image, aligned frames out and the newly created top frame, so you can manually edit it.

-c clips the output picture and rectangles to the same size as the original frames.

-q quits CombineZ when finished.

There are many more options I could add, I'm open to suggestions.

The _spawn function starts CZ, passes the arguments on the command line, and waits for the program to finish.   It should be quite easy to manipulate the folder and file strings programmatically and loop through several runs of CZ with different inputs.

The switches can go anywhere, but the order of the stack, macro and result is important.

alan_hadley@blueyonder.co.uk

p.s. if you have'nt done so lately try Restore Default Macros with this new version of the program, I have made some changesto Do Stack, I hope they are an improvement.