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.
MATLAB: How to get the pixel values of an image according to a given sequence.
image pixel values
Related Solutions
Something like this?
y = x;y(1,end+1) = 1;for i = 2:size(y,1) if y(i,4) == y(i-1,4) y(i,end) = y(i-1,end) + 1; else y(i,end) = 1; endend
**EDIT: Fixed a typo, should work now.
>> X = [1;2;3;4;5;6];>> Y = bsxfun(@plus,X,0:10:40);>> Z = bsxfun(@plus,Y(:),0:20);>> ZZ = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
Best Answer