Last active
August 29, 2015 14:11
-
-
Save lgelman/edf042e8712afa9350ba to your computer and use it in GitHub Desktop.
Shading Correction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// *** Start: White balance *** | |
// | |
name=getTitle(); | |
run("Split Channels"); | |
MeanColor=newArray(3); | |
maxi = 0; | |
for (u=1; u<4; u++) { | |
selectWindow("C"+u+"-"+name); | |
// Type of region, dimensions and position can be changed. | |
// A region in the backgroung (no object) should be choosen. | |
makeRectangle(100,100,100,100); | |
// The user can be prompted to draw a region at that stage. Remove the double slash in the next line. | |
// 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