필터 지우기
필터 지우기

fuzzy clustering only on pixels > zero

조회 수: 1 (최근 30일)
Raheema Al Karim Damani
Raheema Al Karim Damani 2019년 11월 3일
댓글: Image Analyst 2019년 11월 7일
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). The code I am using is not outputting any clustered images, because its throwing an error that "to reshape the number of elements must not change."
Can someone tell me what I am doing wrong?
% cluster the image without clustering the black background
fuzzyT2 = mriAdjust(:,:,15);
[y, x] = find(fuzzyT2)
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개)

Image Analyst
Image Analyst 2019년 11월 5일
idx has the same number of elements as (the badly-named) I.
However z does not. Since some of the binary image idx is presumably false, z will have fewer elements than idx and I. That's why the reshaping does not work.
To get the classified image the same size as the original, you will have to pull a few tricks that I don't have time to tell you since it's late at night, but hopefully you can figure it out before I come back tomorrow.
  댓글 수: 1
Image Analyst
Image Analyst 2019년 11월 7일
I don't have the fuzzy toolbox so I suggest you just step through with the debugger and see that they have different sizes and shapes.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Clustering에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by