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.
 
 

35 lines
903 B

image = imageT;
k = 3;
graph = Image2Graph(image);
%clusters = mySpectralClustering(graph, k);
clusters = myNCuts(graph, k);
clusters = reshape(clusters, size(image, 1), []);
redChannel = image(:, :, 1);
greenChannel = image(:, :, 2);
blueChannel = image(:, :, 3);
segImR = clusters;
segImG = clusters;
segImB = clusters;
for cluster = 1:k
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;
imshow(segIm)
clearvars segImR segImG segImB meanR meanG meanB graph redChannel ...
greenChannel blueChannel clusters k image cluster segIm