First of all, thank you very much for such an incredible work. based on my knowledge, i would've taken a year to write such script. so appreciate that so much. Just one little issue i have encountered. i wonder if it is possible to fix it. If you have a little more time please see the images. I tested the script and learned that it selects more pixels than the very brightest. In other words, it include pixels that are less as bright as the brightests..
i reduced exposure to make sure the difference is clearly visible...