Image processing k-mean clustering
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have an x-ray image and need to segment it using k-mean clustering method. I would like to have two main clusters, (1) the background in blue color and (2) the circles (bubbles)+ long keyhole shape cavity with yellow color. In image "Picture 3" , I indicated what I mean by the bubbles and keyhole that need to be labeled with yellow. However, as the background is not smooth and has scratch lines, the labeled image is not done perfectly. For example , the long keyhole shape is intermittently labeled. I used two types of filters: Flat field correction and Gaussian filter to smooth the background a little bit but was not very helpful. Especially the long keyhole shape will be labeled to several segments as I increased the value of sigma in the filters.
Any suggestions will be appreciated.
clc;clear all; close all;
sigma1=100; % value of sigma2 for gussian filtering
sigma2=1; % value of sigma1 for gussian filtering
img_00=imread('Capture2.jpg');
imshow(img_00)
img_00 = imgaussfilt(img_00,sigma2); % appliying gussian filter 0.5 is default
img_00=imflatfield(img_00,sigma1); % applying image flattening
[L,Centers] = imsegkmeans(img_00,2); % use k-maen clustering to find out keyhole and bubbles, used 2 clusters
B = labeloverlay(img_00,L); % overlay the clustering on the original image
imshow(B)
0 Commenti
Risposta accettata
Ergin Sezgin
il 16 Set 2022
Hello Sam,
You can use Image Segmenter and Image Region Analyzer Apps to accomplish your task, without using k-means. Check the following code:
img = imread("Capture2.jpg");
imgGray = rgb2gray(img);
BW = imgGray > 160;
BW = imclearborder(BW);
BW = bwpropfilt(BW, 'Area',[2500, 20000]);
se = strel('sphere',5);
BW = imdilate(BW,se);
imshowpair(imgGray, BW, "falsecolor")
% BW: Circles and long keyhole shaped cavity
% ~BW: Background
Result plot is obtained as the following:
You can adjust the parameters to make it look better and add new steps if you need.
Hope this helps.
0 Commenti
Più risposte (1)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!