It is strange that segmented_images is allocated as {1 x 3} cell, but afterwards nColors elements should be set to a vector:
segmented_images=cell(1,3);
rgb_label=repmat(pixel_labels,[1 1 3]);
for k=1:nColors
color=RGB;
color(rgb_label~=k)=0;
segmented_images(k)=color;
end
Did you ask the author already? Perhaps this works:
segmented_images=cell(1,nColors);
rgb_label=repmat(pixel_labels,[1 1 3]);
for k=1:nColors
color=RGB;
color(rgb_label~=k)=0;
segmented_images{k}=color;
end
