why do i got blank figure

3 ビュー (過去 30 日間)
MOHAMED GILANI
MOHAMED GILANI 2021 年 11 月 4 日
コメント済み: Abhishek Kolla 2021 年 11 月 15 日
why do i got blank figure after the k means applied?
clear ;
clc;
I = imread('(5)PA5.jpg');
A = rgb2gray(I)
figure(1),imshow(A);title('ORG Image');
%
F = fspecial('gaussian');
G = imfilter(A,F);
figure(5),imshow(G);title('G Image');
figure,
imshow(G);
R = imrect(gca,[50 50 100 100]);
bw= imsegkmeans(G,2);
figure;
imshow(A),title('segmented');
  2 件のコメント
KSSV
KSSV 2021 年 11 月 4 日
Attach your input jpeg image.
MOHAMED GILANI
MOHAMED GILANI 2021 年 11 月 5 日
attached

サインインしてコメントする。

採用された回答

Abhishek Kolla
Abhishek Kolla 2021 年 11 月 11 日
Hi,
I have segmented the image into 2 regions using the k-means clustering algorithm. The document for k-means can be referred here K-means clustering based image segmentation - MATLAB imsegkmeans (mathworks.com)
The following changes have been done to the above code
clear ;
clc;
I = imread('image3.jpg');
figure(1),imshow(I);title('ORG Image');
F = fspecial('gaussian');
G = imfilter(I,F);
figure(5),imshow(G);title('G Image');
[bw,centre]= imsegkmeans(G,2);
t=labeloverlay(G,bw);
figure(7);
imshow(t),title('segmented');
Results for the final segment image
  2 件のコメント
MOHAMED GILANI
MOHAMED GILANI 2021 年 11 月 12 日
how to get it in black&white ?
Abhishek Kolla
Abhishek Kolla 2021 年 11 月 15 日
Hi,
The below code will give the desired result in black and white
clear ;
clc;
I = imread('image3.jpg');
figure(1),imshow(I);title('ORG Image');
F = fspecial('gaussian');
G = imfilter(I,F);
figure(5),imshow(G);title('G Image');
[bw,centre]= imsegkmeans(G,2);
t = label2rgb(bw,im2double(centre));
t1=rgb2gray(t);
%t=labeloverlay(G,bw);
figure(7);
imshow(t1),title('segmented');

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by