// An imageJ macro to be used with exercice 
// by ALM
// Pour avoir les accents, enregistrer en format
// OCCIDENTAL WINDOWS LATIN 1
// sinon ca plante !


setBatchMode(false);

homeDir  =getDirectory("home");
macroDir = getDirectory("SalsaJ")+"Data/images_bh/";
remoteDir="http://www.euhou.net/SalsaJ/Data/images_bh/";

print("Home Dir: "+homeDir);
print("Macro Dir: "+macroDir);
print("Startup Dir: "+getDirectory("startup"));
print("Images Dir: "+getDirectory("image"));
print("Plugins Dir: "+getDirectory("plugins"));

print("Script to study the movements around the Black Hole");
print("Load all the necessary images and adjust contrast");

runMacro("Close_All_Windows.txt");

name="tn000.fts";
openImage(name,macroDir,remoteDir);
name="tn010.fts";
openImage(name,macroDir,remoteDir);
name="tn030.fts";
openImage(name,macroDir,remoteDir);
name="tn050.fts";
openImage(name,macroDir,remoteDir);
name="tn056.fts";
openImage(name,macroDir,remoteDir);
name="tn080.fts";
openImage(name,macroDir,remoteDir);
name="tn086.fts";
openImage(name,macroDir,remoteDir);
name="tn090.fts";
openImage(name,macroDir,remoteDir);
name="tn100.fts";
openImage(name,macroDir,remoteDir);
name="tn102.fts";
openImage(name,macroDir,remoteDir);
name="tn109.fts";
openImage(name,macroDir,remoteDir);

run("Transfrer images dans pile");
run("Dmarrer animation");
run("Images to Stack");
run("Start Animation");

run("Sparer");
run("Tile");
run("Kachel");
run("Separar");
run("Disponi tutto");
run("Mosaico");
run("Sida vid sida");
run("Kaskada");

//run("Grays invert");
//runMacro("PropagateImageInversion");

function openImage(name,localDir,remoteDir){
	//print("name="+name);
	//print("local="+localDir);
	//print("remote="+remoteDir);
	if(! File.exists(localDir+name)){
		path=remoteDir+name;
		open(path);
		if (isOpen(name)) saveAs("FITS",localDir+name);
		else print(""+path+" is not opened");
	}
	else open(localDir+name);
}
