threshold is taken from gui, preprocessing added