Skip to content

Instantly share code, notes, and snippets.

@miura
Created October 30, 2012 21:38
Show Gist options
  • Select an option

  • Save miura/3983246 to your computer and use it in GitHub Desktop.

Select an option

Save miura/3983246 to your computer and use it in GitHub Desktop.
LUT Inversion Test
// LUT Inversion Test
// Created by Jeffrey N. Murphy on 2012.10.30
// Contact on Twitter: @MurphysLab
// http://murphyslab.ca/files/LUT_Inversion_Test.ijm
// added LUT stack output (miura@embl.de)
newImage("Test", "8-bit Ramp", 400, 400, 1);
imgid = getTitle();
print("Grays");
lutcollection = newArray("Grays","Fire","Ice","Spectrum","3-3-2 RGB","Red","Green","Blue","Cyan","Magenta","Yellow","Red/Green");
print("START");
correct = 0; incorrect = 0; inv_incorrect = 0;
for(n=0; n<lutcollection.length; n++){
selectWindow(imgid);
run(lutcollection[n]);
if(0 == is("Inverting LUT")){answer = "PASS"; correct++;} else {answer = "FAIL "; incorrect++;}
print(answer + " 0 = "+is("Inverting LUT") + " " + lutcollection[n]);
// wait(1500);
run("Show LUT");
if (n == 0){
run("Duplicate...", "title=lutstack.tif");
selectWindow("Look-Up Table"); close();
} else {
selectWindow("Look-Up Table");
run("Select All");
run("Copy");
selectWindow("lutstack.tif");
run("Add Slice");
run("Paste");
selectWindow("Look-Up Table"); close();
}
selectWindow(imgid);
run("Invert LUT");
if(1 == is("Inverting LUT")){answer = "PASS"; correct++;} else {answer = "FAIL"; incorrect++; inv_incorrect++;}
print(answer +" 1 = "+is("Inverting LUT") + " " + lutcollection[n]);
run("Show LUT");
selectWindow("Look-Up Table");run("Select All");
run("Copy");
selectWindow("lutstack.tif");
run("Add Slice");
run("Paste");
// wait(1500);
selectWindow("Look-Up Table");close();
selectWindow(imgid);
run("Invert LUT");
}
grade = d2s(correct / (correct + incorrect) * 100,2);
total = correct + incorrect;
inv_grade = d2s((total/2 - inv_incorrect) / (total/2) * 100,2);
print(" ");
print("ALL TESTS");
print("Correct: " + correct + " / " + total);
print("Incorrect: " + incorrect + " / " + total);
print("Grade: " + grade + "% Correct");
print(" ");
print("INVERSION TESTS ONLY");
print("Incorrect: " + total/2 - inv_incorrect + " / " + total/2);
print("Incorrect: " + inv_incorrect + " / " + total/2);
print("Grade: " + inv_grade + "% Correct");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment