Skip to content

Instantly share code, notes, and snippets.

@miura
Created December 8, 2014 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miura/d19f8f51bb489d66d2ff to your computer and use it in GitHub Desktop.
Save miura/d19f8f51bb489d66d2ff to your computer and use it in GitHub Desktop.
// *** Start: White balance ***
name=getTitle();
run("Split Channels");
MeanColor=newArray(3);
maxi = 0;
for (u=1; u<4; u++) {
selectWindow("C"+u+"-"+name);
makeRectangle(100,100,100,100);
// waitForUser("Please draw a region in the background");
getStatistics(area, mean);
MeanColor[u-1] = mean;
if (mean>=maxi) maxi = mean;
}
for (u=1; u<4; u++) {
selectWindow("C"+u+"-"+name);
run("Select None");
run("Multiply...", "value="+maxi/MeanColor[u-1]);
}
run("Merge Channels...", "c1=C1-"+name+" c2=C2-"+name+" c3=C3-"+name+" create");
run("RGB Color");
selectWindow(name); close();
// *** End: While Balance ***
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment