Algo more robust to black only image and no error when no peaks are detected