How can I make each pair of pixels from the matrix in a row major order?

1 vue (au cours des 30 derniers jours)
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....

Réponse acceptée

Darshan Sen
Darshan Sen le 24 Nov 2019
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. :)

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by