error in matlab, cellfun, display image
1 次查看(过去 30 天)
显示 更早的评论
Hello, i have a problem with cellfun
my code:
Z = cellfun(@(Z) Z', Z,'Un',0);
Z = cellfun(@(Z) cell2mat(Z), Z,'Un',0);
Z = cellfun(@(Z) sub2ind(size(I) , Z(:,1) , Z(:,2)), Z,'Un',0);
figure;
cluster = zeros(size(I));
for ii = 1:length(Z)
cluster(Z{ii}) = ii;
end
imshow(label2rgb(cluster))
title('Vystupny obraz - Metoda KMEANS','FontSize',16,'Color','k');
error:
??? Attempted to access Z(:,2); index out of bounds because size(Z)=[952,1].
Error in ==> KMNSimage>@(Z)sub2ind(size(I),Z(:,1),Z(:,2)) at 503
Z = cellfun(@(Z) sub2ind(size(I) , Z(:,1) , Z(:,2)), Z,'Un',0);
Error in ==> KMNSimage at 503
Z = cellfun(@(Z) sub2ind(size(I) , Z(:,1) , Z(:,2)), Z,'Un',0);
Z is :
Z={1x952 cell} {1x3141 cell} {1x3141 cell} {1x3141 cell}
know someone help ?
Thanks.
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!