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

1 visualización (últimos 30 días)
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....

Respuesta aceptada

Darshan Sen
Darshan Sen el 24 de Nov. de 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. :)

Más respuestas (0)

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by