Semester assignments for the course "Digital Image Processing" of THMMY in AUTH university.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
816 B

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