Minggu, 24 November 2013

Deteksi Nukleus




Berikut adalah script MATLAB untuk deteksi INTI SEL (NUCLEI) menggunakan K-MEAN COLOR BASE SEGMENTATION :

he = imread('images/serviks.tif');
imshow(he), title('H&E image');
text(size(he,2),size(he,1)+15,...
     'Image courtesy of Rachmadwati', ...
     'FontSize',7,'HorizontalAlignment','right');
%===============
cform = makecform('srgb2lab');
lab_he = applycform(he,cform);
%=======================
ab = double(lab_he(:,:,2:3));
nrows = size(ab,1);
ncols = size(ab,2);
ab = reshape(ab,nrows*ncols,2);

nColors = 3;
% repeat the clustering 3 times to avoid local minima
[cluster_idx cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean', ...
                                      'Replicates',3);

%===================================


pixel_labels = reshape(cluster_idx,nrows,ncols);
imshow(pixel_labels,[]), title('background,stroma,epitel(nuklei,sitoplasma,basal)');

%===================================
segmented_images = cell(1,3);
rgb_label = repmat(pixel_labels,[1 1 3]);

for k = 1:nColors
    color = he;
    color(rgb_label ~= k) = 0;
    segmented_images{k} = color;
end

figure,imshow(segmented_images{1});
title('Segmentasi 1');
figure,imshow(segmented_images{2});
title('Segmentasi 2');
figure,imshow(segmented_images{3});
title('Segmentasi 3');
%===================================
mean_cluster_value = mean(cluster_center,2);
[tmp, idx] = sort(mean_cluster_value);
blue_cluster_num = idx(1);

L = lab_he(:,:,1);
blue_idx = find(pixel_labels == blue_cluster_num);
L_blue = L(blue_idx);
is_light_blue = im2bw(L_blue,graythresh(L_blue));

%==================================
nuclei_labels = repmat(uint8(0),[nrows ncols]);
nuclei_labels(blue_idx(is_light_blue==false)) = 1;
nuclei_labels = repmat(nuclei_labels,[1 1 3]);
blue_nuclei = he;
blue_nuclei(nuclei_labels ~= 1) = 0;

figure,imshow(blue_nuclei);
title('blue nuclei');

Tidak ada komentar:

Posting Komentar