Generating random blocks of 7-by-7 pixels from a multidimensional array 700 x 800 x 6.
1 次查看(过去 30 天)
显示 更早的评论
Hi, I am new in the programming field and encounter a problem while coding to generate 100 random blocks of 7x7 pixels from a multidimensional array with a size of 700x800x6.Any help in this regard will be highly appreciated
0 个评论
采纳的回答
Walter Roberson
2017-7-18
Easy way: loop
Trickier way:
See https://www.mathworks.com/matlabcentral/answers/348465-hello-been-trying-to-extract-array-from-a-big-matrix-so-because-of-that-taken-magic-5-but-issue-is#comment_468693 and https://www.mathworks.com/matlabcentral/answers/348500-extracting-last-non-nan-200-columns-from-matrix-with-varying-number-of-nans-ending-the-rows#answer_273971 where I show how to extract different columns for each row.
2 个评论
Walter Roberson
2017-7-18
The trickier way is not recommended for beginners!
for K = 1 : 100
r = randi(700-6,1,1);
c = randi(800-6,1,1);
rb{K} = YourData(r:r+6, c:c+6, :);
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resource Allocation Modeling 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!