How to get the pixel values of an image according to a given sequence.?
Show older comments
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.
Accepted Answer
More Answers (1)
Image Analyst
on 1 Jul 2015
Try this:
IM=[12 45 44; 43 13 23; 33 98 99]
SEQ=[1 4 5 8 2 3 9 6 7]
% To get the x and y coordinates:
[y, x] = ind2sub(size(IM), SEQ) % [y, x] is [rows, columns] which ind2sub returns
% To extract the pixel values in column major order
pixelValues = IM(SEQ)
Categories
Find more on Neighborhood and Block Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!