Given a (Nx3) sequence of RGB colors, I want to create a (numRowBlocks x numColBlocks x 3) image comprising (blockSize x blockSize) blocks of those colors in a (numRowBlocks x numColBlocks) pattern.
i.e. for this signature: makeColorBlocks(blockSize, numColBlocks, numRowBlocks, RGBvec)
(Using a weird RGB to make the point)
>> makeColorBlocks(2, 3, 2, [1 11 10;2 22 20; 3 33 30; 4 44 40; 5 55 50; 6 66 60])
ans(:,:,1) =
1 1 2 2 3 3
1 1 2 2 3 3
4 4 5 5 6 6
4 4 5 5 6 6ans(:,:,2) =
11 11 22 22 33 33
11 11 22 22 33 33
44 44 55 55 66 66
44 44 55 55 66 66ans(:,:,3) =
10 10 20 20 30 30
10 10 20 20 30 30
40 40 50 50 60 60
40 40 50 50 60 60Though it can not be mechanically graded as such, I am looking for easy to read an understand code. Something easy to understand is preferred. Thanks to Brett for the question.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers56
Suggested Problems
-
6978 Solvers
-
Find the numeric mean of the prime numbers in a matrix.
9138 Solvers
-
Find the longest sequence of 1's in a binary sequence.
6699 Solvers
-
given 3 sides, find area of this triangle
820 Solvers
-
Project Euler: Problem 6, Natural numbers, squares and sums.
2541 Solvers
More from this Author51
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!