How to create image from arrays by random themself ?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Jonas
2022년 7월 14일
편집: Jonas
2022년 7월 14일
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
Jonas
2022년 7월 14일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!