MATLAB画像処理セグメンテーション処理2

he = imread( 'hestain.png');%画像
図を読み取る; imshow(he)、%display
title( 'H&E image');
text(size(he、2)、size(he、1)+ 15、…
'アラン・パーティン、ジョンズ・ホプキンス大学の画像提供'、...
'のFontSize'、7、 'たHorizo​​ntalAlignment'、 '右');
cform = makecform( 'srgb2lab');の構造Lに%のRGB空間変換のB空間lab_he = applycform(彼、cform);%のRGB空間は、Lに変換されたB空間AB =二重(lab_he(:、:、2:3)); NROWS =サイズ(AB、1); ncolsの=サイズ(AB、2 ); ab = reshape (ab、nrows * ncols、2); nColors = 3; [cluster_idx cluster_center] = kmeans(ab、nColors、 'distance'、... 'sqEuclidean'、 'Replicates'、3);%perform K-means集約クラスpixel_labels = reshape(cluster_idx、nrows、ncols);








figure; imshow(pixel_labels、[])、%は、クラスターの3つの部分を
title( 'クラスターインデックスでラベル付けされた画像'
);
segmented_images = cell(1,3); rgb_label = repmat(pixel_labels、[1 1 3 ]);
for k = 1:nColors
color = he;
color(rgb_label〜 = k)= 0;%kとしてマークされた領域は0に設定されますsegmented_images
{k} = color;
end
figure; subplot(131)
imshow(segmented_images {1))、%最初のクラスター領域の
タイトルを表示( 'クラスター1のオブジェクト'); subplot(132)、
imshow(segmented_images {2})、%2番目のクラスター領域の
タイトルを表示( 'クラスター2のオブジェクト'); subplot(133)、
imshow(segmented_images {3})、%3番目のクラスター領域を表示
title( 'クラスター3のオブジェクト');
mean_cluster_value = mean(cluster_center、2);%平均値を計算
[tmp、idx] = sort (mean_cluster_value);%sort
blue_cluster_num = idx(1);%minimum
L = lab_he(:、:、1);%輝度コンポーネント
blue_idx = find(pixel_labels == blue_cluster_num);%blue area label
L_blue = L(blue_idx);
is_light_blue = im2bw(L_blue、グレイスレッシュ(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;%紺色の領域外の他の領域は0に設定されます
figure、imshow(blue_nuclei)、%は紺色の領域
title( 'blue核 ');
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入
ここに画像の説明を挿入

おすすめ

転載: blog.csdn.net/m0_38127487/article/details/115259638