MATLAB Answers

0

Why 2 images with same cluster value have different representation?

Asked by Mohammad Al Nagdawi on 4 Jan 2017
k-mean cluster classifies pixel randomly. I wrote this code to repeat clustering until both images meet proper cluster.
while 1
idx_fix = kmeans(double(fix(:)),4);
idx_float = kmeans(double(float(:)),4);
idx_fix = reshape(idx_fix,size(fix));
idx_float = reshape(idx_float,size(float));
f1 = idx_fix(127,303);
f2 = idx_float(114,205);
if (f1 == f2)
disp(idx_fix(127,303));
disp(idx_float(114,205));
if (f1 == f2)%when these pixles same that mean this my target classification.
break;
end;
end
end
mat1 = uint8(255*mat2gray(idx_fix));
mat2 = uint8(255*mat2gray(idx_float));
disp(['mat1 = ' num2str(mat1(127,303))]);
disp(['mat2 = ' num2str(mat2(114,205))]);% the value still correct after coversion.
imshow(mat1); title('Fix image class');
hold on
plot(127,303,'or');
hold off;
figure;
imshow(mat2); title('Float image class');
hold on
plot(114,205,'or');
hold off;
similarity_chart(idx_fix,idx_float);
The output image is not as expected. I point the compared pixel by a red circle, however, the area around those circles should have the same color... why this happened?

  0 Comments

Sign in to comment.

0 Answers