Filter löschen
Filter löschen

Make clearer color segmentation.

1 Ansicht (letzte 30 Tage)
Kwanghun Choi
Kwanghun Choi am 25 Okt. 2017
Kommentiert: Kwanghun Choi am 25 Okt. 2017
Hello!! I am a beginner. And I try color segmentation.
two picture is before and after color segmentation. As you see, too many noise and hole are after segmentation.
I just replicate the method which mathwork suppy.(imquantize, Color-Based Segmentation Using K-Means Clustering)
I don't know where is problem.(is code for quantization and clustering wrong? / is color of map poor?) How can I make clear the result?
Are there other good quantization or clustering method?
I know my question is very ambiguous, not concrete. I just want a little hint for better job.
Please advise any suggestion for my work.
function Y2=extcontq(X)
%for color map
%you must control ncolor value for extract clear contour
ncolor=input('ncolor(generally 4) : ');
%Quantization of color image
threshRGB=multithresh(X,7);
threshForPlanes=zeros(3,7);
for i=1:3
thresForPlane(i,:)=multithresh(X(:,:,i),7);
end
value = [0 threshRGB(2:end) 255];
quantRGB=imquantize(X, threshRGB, value);
%clustering
cform=makecform('srgb2lab');
lab_A=applycform(X,cform);
ab=double(lab_A(:,:,2:3));
nrows=size(ab,1);
ncols=size(ab,2);
ab=reshape(ab,nrows*ncols,2);
[cluster_idx,cluster_center]=kmeans(ab,ncolor,'distance','sqEuclidean','Replicates',3);
pixel_label=reshape(cluster_idx,nrows,ncols);
%imshow(pixel_label,[])
%Segmentation
segmented_image = cell(1,3);
rgb_label=repmat(pixel_label,[1 1 3]);
for k=1:ncolor
color=X;
color(rgb_label ~=k)=0;
segmented_image{k}=color;
end
c=1;
while c==1
for i=1:ncolor
imshow(segmented_image{i})
q=input('Do you want this data?(Y=1/N=0)');
if i==ncolor
if q==0
c=input('Return? [Y=1/N=0]');
end
end
if q==1
Y1=segmented_image{i};
c=0;
close all;
break
end
close all;
end
end
%binary
Y2=binary_my(Y1);
imshow(Y2);
d=input('Do you want reverse BW?[Y=1/N=0]');
if d==1
Y2=imcomplement(Y2);
end
close all
Y=Y2;
imshow(Y2);
  2 Kommentare
Walter Roberson
Walter Roberson am 25 Okt. 2017
Which information are you trying to extract?
Kwanghun Choi
Kwanghun Choi am 25 Okt. 2017
Contour line. I want to extract contour line.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!