fiji / Colocalisation_Analysis

Fiji's plugin for colocalization analysis
http://imagej.net/Coloc_2
GNU General Public License v3.0
25 stars 18 forks source link

Auto threshold regression: refactor type range checks #3

Closed tomka closed 9 years ago

tomka commented 9 years ago

As stated in 0bee4e20 the introduced range checks could be improved. This change makes the code more readable and more DRY by factoring the clamping into its own function. Two more places were simplified additionally.

tomka commented 9 years ago

I removed the this. prefix and rebased on current master. Regarding the performance issues: Before adding the pull request, I compared timings of the Math.min/Math.max version with the existing if/then/else version (factored into the clamp method) and could not find any performance differences.

tomka commented 9 years ago

@dscho, even though there are no performance differences between the clamping implementation you suggested and I came up with (on my machine), I changed the commit to include your version. It doesn't hurt and might be safer if there are maybe Java versions out there that can't inline Math.min and Math.max. Thanks for the suggestion.

dscho commented 9 years ago

Thanks.