Adaptive Thresholding and Contour Detection in Noisy Images: A Practical Approach