How can I make each pair of pixels from the matrix in a row major order?
1 次查看(过去 30 天)
显示 更早的评论
Imag A=[ 43 36 31 35 35 29 29 25
33 33 32 29 25 25 22 22
33 33 31 32 31 27 25 29
28 33 35 27 25 29 32 51
23 26 30 38 31 43 47 57
27 29 30 37 40 52 63 61
23 24 32 42 52 62 72 66
24 30 44 54 65 71 70 74 ]
How can I make each pair of pixels from the matrix in a row major order? Such as (43,36)-first pair, (31,35)-second pair, (35,29)-third pair etc....
0 个评论
采纳的回答
Darshan Sen
2019-11-24
Hello Subroto. I have used a couple of steps to convert A into a vector of paired up pixels and stored it in A_paired.
>> A=[43 36 31 35 35 29 29 25
33 33 32 29 25 25 22 22
33 33 31 32 31 27 25 29
28 33 35 27 25 29 32 51
23 26 30 38 31 43 47 57
27 29 30 37 40 52 63 61
23 24 32 42 52 62 72 66
24 30 44 54 65 71 70 74 ];
>> A_transpose = A';
>> A_vector = A_transpose(:);
>> A_paired = reshape(A_vector, 2, length(A_vector) / 2)'
A_paired =
43 36
31 35
35 29
29 25
33 33
32 29
25 25
22 22
33 33
31 32
31 27
25 29
28 33
35 27
25 29
32 51
23 26
30 38
31 43
47 57
27 29
30 37
40 52
63 61
23 24
32 42
52 62
72 66
24 30
44 54
65 71
70 74
I hope this was helpful. :)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!