Created
June 17, 2025 11:11
-
-
Save romainGuiet/d22de7d73b40a597ab099c7074533d13 to your computer and use it in GitHub Desktop.
thresholds on gel image
This file contains hidden or 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
| // clear the environment | |
| run("Close All"); | |
| run("Clear Results") | |
| roiManager("Reset"); | |
| // Set the measurements of intererest | |
| run("Set Measurements...", "area mean standard min limit display redirect=None decimal=3"); | |
| run("Gel (105K)"); | |
| rename("Original"); | |
| waitForUser("There are several factors than can create variability in acquisition,"+ | |
| "\nthat will make grey levels a little bit different"+ | |
| "\nfrom one image to another even if the object is the same." | |
| ); | |
| run("Gel (105K)"); | |
| rename("Lower"); | |
| run("Add...", "value=-8"); | |
| run("Gel (105K)"); | |
| rename("Higher"); | |
| run("Add...", "value=25"); | |
| run("Tile"); | |
| waitForUser("Let's now look at the corresponding histograms"); | |
| image_Nbr = nImages; | |
| for (i = 1 ; i <= image_Nbr ; i++){ | |
| selectImage(i); | |
| run("Histogram"); | |
| } | |
| run("Tile"); | |
| waitForUser("We can see that 'min' and 'max' are different for the 3 images"+ | |
| "\nBUT the histograms are equivalent."+ | |
| "\nLet's apply an arbitrary threshold on the images, like 81 ! " | |
| ); | |
| for (i = 1 ; i <= image_Nbr ; i++){ | |
| selectImage(i); | |
| setThreshold(0, 81); | |
| run("Measure"); | |
| } | |
| waitForUser("We can see that '81' is maybe note the 'right' value for all the images"+ | |
| "\nLet's apply the same algorithm threshold on the images (Shanbhag)" | |
| ); | |
| for (i = 1 ; i <= image_Nbr ; i++){ | |
| selectImage(i); | |
| setAutoThreshold("Shanbhag"); | |
| run("Measure"); | |
| } | |
| waitForUser("We can now realize that the Area is the same for all the images"+ | |
| "\nwhile other parameters (like the mean) can show difference."+ | |
| "\nThat's why we like so much 'Auto_Thresholding'"+ | |
| "\nit's able to compensate for small fluctuations between images"+ | |
| "\nand still robust results."+ | |
| "\n..."+ | |
| "\nLet's see now what happen if you work with saturated images." | |
| ); | |
| selectImage("Lower"); | |
| setMinAndMax(50, 255); | |
| run("Apply LUT"); | |
| selectImage("Higher"); | |
| setMinAndMax(0, 200); | |
| run("Apply LUT"); | |
| selectImage("Histogram of Lower"); | |
| close(); | |
| selectImage("Histogram of Higher"); | |
| close(); | |
| for (i = 2 ; i <= image_Nbr ; i++){ | |
| selectImage(i); | |
| run("Histogram"); | |
| } | |
| run("Tile"); | |
| waitForUser("With 'some' saturation we see that the histograms are dramatically affected"+ | |
| "\nLet's check the result of thresholding." | |
| ); | |
| for (i = 1 ; i <= image_Nbr ; i++){ | |
| selectImage(i); | |
| setAutoThreshold("Shanbhag"); | |
| run("Measure"); | |
| } | |
| waitForUser("Nothing has much more sense anymore..."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment