clustering is working but untested. changed shape of intensity array.