function ximage = NLpredictor(yimage, M, partition)
% piece-wise linear predictor

% predicts ximage using yimage
% M is the coefficients table
% partition is the cell number for each pixel


n = 1;
[row col] = size(yimage);
Y = [ones([1 row*col]); imageVectors(yimage,n, 1)];
[a maxcells] = size(M);
partvect = min(imageVectors(partition, 0), maxcells-1);
coeffs = M(:, partvect+1);
Y2 = coeffs.*Y;
X = sum(Y2);
ximage = reshape(X, [row col]);
