debugged slic algorithm