User Tools

Site Tools


documents:120206pyip_cooking:python_imagej_cookbook

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
documents:120206pyip_cooking:python_imagej_cookbook [2017/12/03 05:03]
kota [Automatic Brightness/Contrast Button] updated github repo link
documents:120206pyip_cooking:python_imagej_cookbook [2017/12/03 06:08] (current)
kota [Automatic Brightness/Contrast Button] human language explanation added
Line 972: Line 972:
       - if the count exceeds "​limit",​ then count becomes 0       - if the count exceeds "​limit",​ then count becomes 0
       - if the count is larger than "​threshold",​ then that value is the maximum. ​       - if the count is larger than "​threshold",​ then that value is the maximum. ​
 +
 +Explanation in human language: this algorithm first determines two values "​limit"​ and "​Threshold"​. ​
 +
 +"​Threshold"​ is the parameter that actually sets the min and the max of the contrast curve for the automatic enhancement. Starting from the lowest pixel value (0) or the highest value (255), the algorithm determines the number of pixels with that pixel value. If the number exceeds 0.02% of total pixel number, then that pixel value becomes wither the min or the max for enhancing the contrast. For this decision to ignore background pixels, the algorithm also needs to have another decision determining the background pixel value. ​
 +
 +"​limit"​ actually is a fixed number for each image to decide which of black (0) or white (255) is the background. If the number of pixels with current pixel value is more than 10% of total pixel number, then that value is considered to be the background of the image. For example, when the number of pixels with the value of 0 is 15%, then pixels with 0 values are background. In the next step, if pixels with the value of 1 are still over 10% like 11%, then pixels with values <= 1 are background. When the background is white, then similar decision takes place in the second loop. 
  
 The Jython script shown below is the re-written version based on original Java code. You could see the Java code of method "​autoadjust" ​ [[https://​github.com/​imagej/​imagej1/​blob/​master/​ij/​plugin/​frame/​ContrastAdjuster.java#​L780-L829|in the git repo]], line 780-829. ​ The Jython script shown below is the re-written version based on original Java code. You could see the Java code of method "​autoadjust" ​ [[https://​github.com/​imagej/​imagej1/​blob/​master/​ij/​plugin/​frame/​ContrastAdjuster.java#​L780-L829|in the git repo]], line 780-829. ​
documents/120206pyip_cooking/python_imagej_cookbook.txt ยท Last modified: 2017/12/03 06:08 by kota