function segIm = meanClustersColorRGB(image, clusters) %MEANCLUSTERSCOLOR Summary of this function goes here % Detailed explanation goes here redChannel = image(:, :, 1); greenChannel = image(:, :, 2); blueChannel = image(:, :, 3); segImR = clusters; segImG = clusters; segImB = clusters; for cluster = 1:max(max(clusters)) meanR = mean(redChannel(clusters == cluster)); meanG = mean(greenChannel(clusters == cluster)); meanB = mean(blueChannel(clusters == cluster)); segImR(clusters == cluster) = meanR; segImG(clusters == cluster) = meanG; segImB(clusters == cluster) = meanB; end segIm = zeros(size(image, 1), size(image, 2), 3); segIm(:, :, 1) = segImR; segIm(:, :, 2) = segImG; segIm(:, :, 3) = segImB; end