COLOR IMAGE SEGMENTATION BASED ON MEAN SHIFT using MATLAB with code
Code:
clc
close all
warning off
rgbImage=imread('peppers.png');
subplot(1,3,1);
imshow(rgbImage);
title('Original
Image');
ax=gca;
ax.TitleFontSizeMultiplier=2;
redChannel=rgbImage(:, :, 1);
greenChannel=rgbImage(:, :, 2);
blueChannel=rgbImage(:, :, 3);
data=double([redChannel(:), greenChannel(:), blueChannel(:)]);
[n,m,not_required] = MeanShiftCluster(data',60,0);
n=n';
m=reshape(m',size(rgbImage,1),size(rgbImage,2));
n=n/255;
clusteredImage=label2rgb(m,n);
subplot(1,3,2);
imshow(clusteredImage);
title('High
Radius');
ax=gca;
ax.TitleFontSizeMultiplier=2;
[n,m,not_required] = MeanShiftCluster(data',10,0);
n=n';
m=reshape(m',size(rgbImage,1),size(rgbImage,2));
n=n/255;
clusteredImage=label2rgb(m,n);
subplot(1,3,3);
imshow(clusteredImage);
title('Small
Radius');
ax=gca;
ax.TitleFontSizeMultiplier=2;
No comments