Reducing time to initialize variables
Getting reference to data of imageaData once
Extracted constant
Putting Math.floor outside the loop
one less variable within loop