If you have the data stored in the variable YourArray then
tells you the class of the image. It might be uint8 or double (both are common) or any of the other numeric data types. It could even be logical.
MATLAB treats images differently depending on which datatype is being used. For any of the integer data types, MATLAB treats 0 as black and treats intmax of the class (such as 255 for uint8) as being full signal. For double or single images, 0 is black and 1 is full strength, for RGB images or grayscale images. (It is also possible to have pseudocolor images for which the numbers would be positive integers and would be treated as indexes into a color table.)
"Determine the class of the image" can be done by calling class() and passing in the name of the variable that holds the image data. Also, if you have a file name, you can examine the output of imfinfo() applied to the file name.
It is also important to know whether the image data is 2 dimensional or 3 dimensional. 3 dimensional arrays must be RGB images, and the data for them must be directly given by the integer value for uint8 or uint16, or must be given by the 0 to 1 range for single or double precision. 2 dimensional arrays can be grayscale or binary or pseudocolor or arbitrary intensity to be mapped to color later.
You would normally create a color image by using imread() to read it in.
YourImage = imread('lena.jpg');
If you need to create one "manually" then create a 3 dimensional matrix. For example,
YourImage = zeros(64, 80, 3, 'uint8');
YourImage(1:32, :, 1) = 127;
YourImage(33:end, :, 1) = 200;
YourImage(:, 20:60, 2) = 53;
YourImage(:,61:end, 3) = 255;
If you have individual red and green and blue matrices, then for example
RedMatrix = zeros(64, 80, 'uint8');
RedMatrix(1:32, :) = 127;
RedMatrix(33:end, :) = 200;
GreenMatrix = zeros(64, 80, 'uint8');
GreenMatrix(:, 20:60) = 53;
BlueMatrix = zeros(64, 80, 'uint8');
BlueMatrix(:,61:end) = 255;
YourImage = cat(3, RedMatrix, GreenMatrix, BlueMatrix);