I want follow up with more matrix performance observations.
I converted all of my new script's image processing code to use Matrix instead of Array. Image.toMatrix() is much faster than Image.getSamples(Array). But for all other code without exception Matrix usage is no faster and often slower than Array usage in Win 7 1123.
It appears calls to Matrix.rows, Matrix.cols, and Matrix.at() are relatively expensive performance wise and are not optimized by the script compiler. So for best performance it is best to hand optimize code to minimize their use as much as possible.
As a trivial example, code to square a matrix element wise
for (var row = 0; row != matrix.rows; ++row) {
for (var col = 0; col != matrix.cols; ++col) {
newMatrix.at(row, col, matrix.at(row, col) * matrix.at(row, col));
}
}
is better written
var rows = matrix.rows;
var cols = matrix.cols;
for (var row = 0; row != rows; ++row) {
for (var col = 0; col != cols; ++col) {
var e = matrix.at(row, col)
newMatrix.at(row, col, e * e);
}
}
Mike