Some people want to know how to view the segmented image. For example suppose you have two classes ie k=2; us the following code to view it
[row col] = size(ima);
final_img = zeros(row,col);
This is a naive way of viewing it .. you may have to change somethings if k>2. Anywayz hope it helps. The mask basically stores the segmented image.