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

setBatchMode(false);

macroDir = "/Users/melchior/EUHOU/SalsaJ/Release/Data/imagesFT_Corot-2b/"
remoteDir="http://www.euhou.net/SalsaJ/Data/imagesFT_Corot-2b/";
homeDir=getDirectory("home");
print("Script to study the transit of Corot-2b");
print("Load the image files, extract a small area and adjust the intensity thresholds");

runMacro("Close_All_Windows.txt");

for (i=102; i<=201; i=i+3) {
    name="Extract_b_e_20120620_"+i+"_1_1_1.fits";
//openImage(name,macroDir,remoteDir);
	file=macroDir+name; open(file);
	run("Enhance Contrast", "saturated=0.5");
	run("Enhance Contrast", "saturated=0.5");
}

run("Images to Stack");
run("StackReg");
//run("Stack to Images");
//for (i=1; i<100; i++) {
//        selectImage(i);
//	run("Enhance Contrast", "saturated=0.5");
//	run("Enhance Contrast", "saturated=0.5");
//}
//run("Tile");
//run("Séparer");
//run("Tile");
//run("Kachel");
//run("Separar");
//run("Disponi tutto");
//run("Mosaico");
//run("Sida vid sida");
//run("Kaskada");

// Propagates the display range of the current image
//  to all open images of the same type.

//    if (nImages<=1) exit;
//    getMinAndMax(min, max);
//    depth = bitDepth();
//    if (depth==24) exit;
//    id = getImageID;
//    for (i=1; i<=nImages; i++) {
//         Selectimage(i);
//         if (depth==bitDepth && getImageID!=id)
//             setMinAndMax(min, max);

//    }

run("Transférer images dans pile");
