Re: Populating a matrix with pixel values



thanks for the help. i have another question though. how do i reshape the matrix if in your code, the '1:25' values were placed with pixel intensity values pulled from specific x and y coordinates from an image? Would you know how to pull those pixel values from an image and reshape them?

thanks,

m.k.

"us " <us@xxxxxxxxxxxxxxx> wrote in message <f8nqrp$g01$1@xxxxxxxxxxxxxxxxxx>...
m. k:
<SNIP extracting data from an image...

one of the solutions

% the image
img=reshape(1:25,[5,5]);
rc=2; % submat center: row
cc=4; % submat center: col
ms=3; % submat size: 3x3 == odd
% the engine
ns=floor(ms/2);
% ...error checking comes here!
m=img(rc-ns:rc+ns,cc-ns:cc+ns);
% the result
img
m

us

.