Unsupervised colour clustering using the k-means algorithm.
function call:
[out_img1,out_img2,num1]=vsg('SICluster',in_img1);
Arguments:
in_img1 - input
image, 3 channel RGB, 1 channel greyscale or binary image.
Description:
The function
SICluster applies the Unsupervised K-mean clustering for image
segmentation.
out_img1
– an image with the same dimensions as the input image which is the
input image with a reduced number of colours. The colours are estimated
such that the difference between the input and output images is
minimised.
out_img2
– an image with the same dimensions as the input image which is an image
of the colour labels. i.e. each colour is numbered, and it is these
numbers that are output in this image.
The num – an
integer indicating the number of colour clusters found.
Example:
img = imread('lake.jpg');
h=figure;image(img);set(h,'Name','Input');
[out_img1,out_img2,num1]=vsg('SICluster',img);
h=figure; image(uint8(out_img1));set(h,'Name','SICluster');
h=figure; imagesc((out_img2(:,:,1)));set(h,'Name','SICluster_Label');
This function starts off with 32 colours, all selected based on histogram analysis.