Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

error in kmeans?

1 Ansicht (letzte 30 Tage)
tan yuki
tan yuki am 5 Apr. 2016
Geschlossen: Walter Roberson am 5 Apr. 2016
i try to apply kmeans on an image but it keeps on error. the coding is as shown below. pls advice.
I=imread('....');
im=rgb2gray(I);
data=double(im(:));
nrows = size(data,1);
ncols = size(data,2);
data = reshape(data,nrows*ncols,1);
[idx,C] = kmeans(data,3)
b=uint8(C==1);
b1=b*255;
figure, imshow(b1),title('Object 1');
L1=bwlabel(b1);
stats = regionprops(L1,'Centroid','Area','BoundingBox');
area1=[stats.Area];
sprintf('area1 = %d', area1)
c=uint8(C==2);
c1=c*255;
figure, imshow(c1),title('Object 2');
L2=bwlabel(c1);
stats2 = regionprops(L2,'Centroid','Area','BoundingBox');
area2=[stats2.Area];
sprintf('area2 = %d', area2)
d=uint8(C==3);
d1=d*255;
figure, imshow(d1),title('Object 3');
L3=bwlabel(d1);
stats3 = regionprops(L3,'Centroid','Area','BoundingBox');
area3=[stats3.Area];
sprintf('area2 = %d', area3)

Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by