If you please I want to link this instruction{ rgbImage = cat(3, redChannel, greenChannel, blueChannel);} with the rand() function until I get the following result ,,,How to do it

2 views (last 30 days)
abory kikla
abory kikla on 13 Mar 2016
If you please I want to link this instruction{ rgbImage = cat(3, redChannel, greenChannel, blueChannel);} with the rand() function until I get the following result ,,,How to do it
  1 Comment
Jan
Jan on 14 Mar 2016
The question is not clear. Do you know how to create the image? Should the image appear in a figure or do you want to save it in an image file? Does the size of the patchs matter?

Sign in to comment.

Answers (3)

Walter Roberson
Walter Roberson on 29 Mar 2016
Hint: randomly select color numbers. kron() with ones() to make copies of the numbers.
  8 Comments
Walter Roberson
Walter Roberson on 30 Mar 2016
However, it does not need to be randomly colored. Also it is not clear that it requires using both of those: it could be requiring that you use at least one of them.

Sign in to comment.


Geoff Hayes
Geoff Hayes on 13 Mar 2016
abory - it isn't clear to me why you need to use cat or how you would link this with rand. Presumably, you wish to create randomly coloured squares and then patch them together. Rather than use cat and rand, I may do something like
% define the number of squares per edge (where the edge is the row or column)
numSqrsPerEdge = 8;
% define the number of pixels per square edge
numPixelsPerSqrEdge = 25;
The above would give us an 8x8 square of squares, where each sub-square is 25x25 whose colour is randomly generated.
To generate any one sub-square, you could do randi as
% generate the random colour
sqrColour = uint8(randi(256,1,1,3) - 1);
% create the sub-square
subSquare = repmat(sqrColour, numPixelsPerSqrEdge, numPixelsPerSqrEdge);
You can use the above for each of the 64 (8x8) sub-squares, concatenating or (perhaps better) inserting each sub-square into an already sized 8x8 (or 200x200x3) array.
  5 Comments

Sign in to comment.


Muhammad Usman Saleem
Muhammad Usman Saleem on 26 Mar 2016
use imread and then imshow.. Not understand your question?
  5 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!