RGB % values of an image (MATLAB code)

 I = imread('C:\xxx.jpg');
rgb_percent = squeeze(sum(sum(I,1),2))/sum(I(:))*100

rgb_percent =

   27.3365
   34.4873
   38.1762