We developed a method to systematically choose an optimal threshold value. The algorithm applies a wide range of threshold values to a single AFM images and for each threshold image, computes the number of connected components (connected components representing individual fibers). As the threshold value was increased, if the number of connected components plateaues, the threshold value corresponding to the plateau is chosen.