Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create RGB from Matrices

Status
Not open for further replies.

Gurdz50

Computer
Feb 4, 2006
1
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.
 
Replies continue below

Recommended for you

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor