How to get the pixel values of an image according to a given sequence.?
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 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)
1 Kommentar
Jeena
am 1 Jul. 2015
Kategorien
Mehr zu Neighborhood and Block Processing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!