Animation of Mean Shift segmentation using MATLAB (with complete code)
clc
clear all
close all
warning off
preprocessing={};
rgbImage=imread('peppers.png');
redChannel=rgbImage(:, :, 1);
greenChannel=rgbImage(:, :, 2);
blueChannel=rgbImage(:, :, 3);
data=double([redChannel(:), greenChannel(:), blueChannel(:)]);
temp=100;
for
i=10:100
[n,m,not_required] =
MeanShiftCluster(data',i,0);
n=n';
m=reshape(m',size(rgbImage,1),size(rgbImage,2));
n=n/255;
clusteredImage=label2rgb(m,n);
preprocessing{temp}=clusteredImage;
temp=temp-1;
end
for
i=1:length(preprocessing)
subplot(1,2,1);
imshow(rgbImage);
title('Orignial Image');
ax=gca;
ax.TitleFontSizeMultiplier=2;
subplot(1,2,2);
imshow(preprocessing{i});
title('Segmented Image(Bandwidth
Decreasing)');
ax=gca;
ax.TitleFontSizeMultiplier=2;
pause(0.3);
end
No comments