Function Reference
— Function File: flag = isrgb (A)

Returns true if parameter is a RGB image.

flag=isrgb(A) returns 1 if A is a RGB image and 0 if not.

To the decide isrgb uses the follow algorithm:

  • If A is of class double then it checks if all values are between 0 and 1, and if size is m-by-n-by-3.
  • If A is of class uint16, uint8 or logical then it checks is m-by-n-by-3.

Compatibility notes:

Information needed on whether MATLAB accepts logical arrays as RGB images (now this functions accepts them if they are m-by-n-by-3 arrays.

Demonstration 1

The following code

 isrgb(rand(1,2,3))
 # A 1-by-2-by-3 double matrix with elements between 0 and 1 is a RGB image.

Produces the following output

ans =  1