Probably your RGB-matrices are e.g. in format uint8
or uint16
, as this is the output format of image import functions for a lot of file types. As power
intends not to violate the format definition, which it would for fractional powers, it throws the error.
So basically you only have to change lines 2-4 to:
R = double( img_src(:,:,1) );
G = double( img_src(:,:,2) );
B = double( img_src(:,:,3) );
and your code should work as desired.