It's not as easy as your code implies. Your code will give you the position of the last pixel it finds that is brighter than your threshold.
You'll have to define a bounding box for all of those pixels, then calculate the center of the box for the approximate position. This would also help you take into account the distance to the light source and it's shape. Since a source closer to the camera will appear larger than one farther away from the camera.
If you're looking at doing more than this, your task just got much more difficult. You can find an example
here[
^].