Generating random blocks of 7-by-7 pixels from a multidimensional array 700 x 800 x 6.
1 view (last 30 days)
Show older comments
Chandrama Sarker
on 18 Jul 2017
Commented: Walter Roberson
on 18 Jul 2017
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 Comments
Accepted Answer
Walter Roberson
on 18 Jul 2017
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 Comments
Walter Roberson
on 18 Jul 2017
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
More Answers (0)
See Also
Categories
Find more on Resource Allocation Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!