Fuzzy CMeans Usage Image Segmentation
Posted: Aug 23, 2006 12:29 PM PlainText Reply
Hi, Ofek:
Thank you very much for your answers. They all worked for me. Now my code is capable of identifying all clusters of the image (and I
extended its capabilities a little). I will try now the same code with my MRI images.
Yours sincerely,
JanKees
Ofek Shilon wrote:
> > choosing four colors, my code now is (nColors > > =
> > 4): > >
> > % instead of "segmented_images = cell(1, 3);" > > segmented_images = cell(1, 4);
>
> i recommend just
> segmented_images = cell(1,nColors); >
> > % instead of "rgb_label = repmat(pixel_labels,[1 1 3]);" > > rgb_label = repmat(pixel_labels,[1 1 4]);
>
> actually this is a mistake. keep the [1 1 3] repetition vector it's > designed to repeat the label matrix over the triplet of RGB image > colors.
> > >
> > for k = 1:nColors > > color = he;
> > color(rgb_label ~= k) = 0; > > segmented_images{k} = color; > > end
> >
> > Here, the forloop causes the following error: > >
> > ??? Attempt to grow array along ambiguous dimension. > >
> > Error in ==> color(rgb_label ~= k) = 0; > >
>
> this will work now. >
> the actual image rendering isn't looped in the demo, so add >
> %%
> imshow(segmented_images{4}), title('objects in cluster 4'); >
> right after the imshow if image 3. >