setBatchMode(false);

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

print("Script display the circumstellar disk around Beta Pictoris");
print("Load the two image files and adjust the threshold on the resulting image");

runMacro("Close_All_Windows.txt");

name="bpic.tif";
openImage(name,macroDir,remoteDir);
setMinAndMax(59., 11133.);

name="ref.tif"; 
openImage(name,macroDir,remoteDir);
setMinAndMax(59., 11133.);


imageCalculator("Subtract create", "bpic.tif","ref.tif");
//run("Oprations entre images", "image=bpic.tif opration=Soustraction image=ref.tif create");

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

//run("Image Calculator...", "image1=\bpic.fts operation=Subtract image2=\ref.fts create");

run("Enhance Contrast", "saturated=0.5");
setMinAndMax(-2.000000000, 13.000000000);


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);
}
