MATLAB: How to get the pixel values of an image according to a given sequence.

image pixel values

Let the image be a 3*3 matrix [12 45 44; 43 13 23; 33 98 99] and let there be a sequence [1 4 5 8 2 3 9 6 7]. I have to select the pixel values in the order of the given sequence and to output the x and y coordinates of each. ie., I have to select 1st element of image matrix and to get its coordinate values, then 4th element and so on.

Best Answer

IM=[12 45 44; 43 13 23; 33 98 99]
SEQ=[1 4 5 8 2 3 9 6 7]
[x,y]=ind2sub(size(IM),SEQ)