Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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....

Risposta accettata

Darshan Sen
Darshan Sen il 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. :)

Più risposte (0)

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by