How to get the pixel values of an image according to a given sequence.?
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Image Analyst
el 1 de Jul. de 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 comentario
Jeena
el 1 de Jul. de 2015
Categorías
Más información sobre Neighborhood and Block Processing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!