reshaping error after clustering pixels > 0 in image
显示 更早的评论
Updated: I have an image in which I have isolated the tumor region using thresholding (img 1) . Now im trying to use fuzzy clustering to cluster the pixels in just the tumor ROI but not the black background (basically ignore any pixels = 0 in clustering).When I try to segment the clusters into images it s not outputting any clustered images, because its throwing an error that "to reshape the number of elements must not change." I've been trying to edit my code but the results are the same.
fuzzyT2 = mriAdjust(:,:,15);
[y, x] = find(fuzzyT2)
%pre-allocating a new variable re_fuzzyT2 that is the row numbers of ab that are not all zero;
re_fuzzyT2 = fuzzyT2(111:182,69:123); %72 x 55 uint16
%create output = pixel_label as zeros of the proper shape
cluster_center = im2uint16(zeros(256,256));
%store results of clustering ab(idx,:) into pixel_label(idx)
idx = fuzzyT2 > 0 %creates a mask for true value for all nonzero pixels
z = fuzzyT2(idx);
%% fuzzy c-means
G = 4
z = double(z)
[cluster_idx, cluster_center, obj] = fcm(z, G)
% reshape into four 2-D array
cluster1 = cluster_center(1,:);
cluster2 = cluster_center(2,:);
cluster3 = cluster_center(3,:);
cluster4 = cluster_center(4,:)
imIDX1 = reshape(cluster1, size(idx));
imIDX2 = reshape(cluster2, size(idx));
imIDX3 = reshape(cluster3, size(idx));
imIDX4 = reshape(cluster4, size(idx));
subplot(2,2,1), imshow(img_1), title('cluster 1')
subplot(2,2,2), imshow(img_2), title('cluster 2')
subplot(2,2,3), imshow(img_3), title('cluster 3')
subplot(2,2,4), imshow(img_4), title('cluster 4')
1 个评论
Adam Danz
2019-11-6
I just saw that Image Analyst had already explained why the error was happening:
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Encryption / Cryptography 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!