mathematical morphology for javascript