×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Create RGB from Matrices

Create RGB from Matrices

Create RGB from Matrices

(OP)
Hello All,

I am new to matlab and am wondering if there is a function available that is able to create an RGB image from a number of matrices which are of the format:

Matrix1: [0.06, 0.02; 0.3, 0.02]
Matrix2: [0.09, 0.01; 0.7, 0.03]
Matrix3: [0.1, 0.03; 0.4, 0.9]

Where each matrix represents a ratio of Red, Green or Blue. I would like to show the 3 matricies as one matrix (same dimensions as the above) with each cell having a double representation of the RGB value.

I hope my query is clear, many thanks for your help in advance.

RE: Create RGB from Matrices

MATLAB can use an MxNx3 matrix to represent a RGB image, with each MxN submatrix representing RGB color intensities.  The help on the image command can explain this further.

If you have three MxN matricies red, green, blue you can create the RGB matrix in several ways.  I have used the following two: (this assumes you have already defined m, n, red, green and blue)

CODE

I = zeros(m, n, 3);
I(:, :, 1) = red;
I(:, :, 2) = green;
I(:, :, 3) = blue;

Or alternately:

CODE

I = reshape([red; green; blue], m, n, 3);

Eric

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources