Daniel@0: function g = rgb2grayKPM(rgb) Daniel@0: % function g = rgb2grayKPM(rgb) Daniel@0: % rgb2grayKPM Like the built-in function, but if r is already gray, does not cause an error Daniel@0: Daniel@0: [nr nc ncolors] = size(rgb); Daniel@0: if ncolors > 1 Daniel@0: g = rgb2gray(rgb); Daniel@0: else Daniel@0: g = rgb; Daniel@0: end Daniel@0: