How to create image from arrays by random themself ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jenifer NG
am 14 Jul. 2022
Kommentiert: Jenifer NG
am 14 Jul. 2022
Dear all,
I want to create a image by using defined arrays a b c in a ramdom step to get a image 44x400 pixel
Could anyone help me?
a = [119 79 76 101 119 99 72 77 94 82 76 84 92 86 63 54 45 47 59 69 56 59 52 48 48 41 41 38 41 42 38 42 36 30 35 17 23 29 29 31 27 18 17 51]
b = [144 118 123 109 88 78 77 71 78 80 74 82 87 78 71 59 39 53 35 37 41 40 26 37 40 38 31 36 40 35 36 31 33 37 23 27 24 32 23 27 28 23 5 32]
c = [133 112 97 92 79 75 78 74 60 74 72 68 76 70 60 54 56 46 43 54 46 40 43 41 41 36 41 39 34 30 17 17 30 16 10 21 26 30 29 21 18 11 19 48]
newimage = [ a
b
c
b
c
c
b
a
....
400]
0 Kommentare
Akzeptierte Antwort
Jonas
am 14 Jul. 2022
Bearbeitet: Jonas
am 14 Jul. 2022
a = [119 79 76 101 119 99 72 77 94 82 76 84 92 86 63 54 45 47 59 69 56 59 52 48 48 41 41 38 41 42 38 42 36 30 35 17 23 29 29 31 27 18 17 51];
b = [144 118 123 109 88 78 77 71 78 80 74 82 87 78 71 59 39 53 35 37 41 40 26 37 40 38 31 36 40 35 36 31 33 37 23 27 24 32 23 27 28 23 5 32];
c = [133 112 97 92 79 75 78 74 60 74 72 68 76 70 60 54 56 46 43 54 46 40 43 41 41 36 41 39 34 30 17 17 30 16 10 21 26 30 29 21 18 11 19 48];
together=[a;b;c];
numOfRows=400;
randomRowsIdx=randi(3,numOfRows,1);
together(randomRowsIdx,:)
note that the result is 400x44 and not 44x400.
4 Kommentare
Jonas
am 14 Jul. 2022
just run
randomRowsIdx=randi(3,numOfRows,1);
together(randomRowsIdx,:)
inside your loop and write the rest of the code before it:
a = [119 79 76 101 119 99 72 77 94 82 76 84 92 86 63 54 45 47 59 69 56 59 52 48 48 41 41 38 41 42 38 42 36 30 35 17 23 29 29 31 27 18 17 51];
b = [144 118 123 109 88 78 77 71 78 80 74 82 87 78 71 59 39 53 35 37 41 40 26 37 40 38 31 36 40 35 36 31 33 37 23 27 24 32 23 27 28 23 5 32];
c = [133 112 97 92 79 75 78 74 60 74 72 68 76 70 60 54 56 46 43 54 46 40 43 41 41 36 41 39 34 30 17 17 30 16 10 21 26 30 29 21 18 11 19 48];
together=[a;b;c];
numOfRows=400;
for x=1:3
randomRowsIdx=randi(3,numOfRows,1);
myCurrentImage=together(randomRowsIdx,:)
end
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!