Can anyone help me to segment the stone from the kidney image

5 次查看(过去 30 天)
Hi
I am using k means clustering algorithm and this is code i have used
grayLevels = double(grayImage(:));
[clusterIndexes, clusterCenters] = kmeans(grayLevels, numberOfClusters,...
'distance', 'sqEuclidean', ...
'Replicates', 2);
labeledImage = reshape(clusterIndexes, rows, columns);
subplot(2, 2, 2);
figure,imshow(labeledImage,[]);
caption = sprintf('k-means with %d clusters', numberOfClusters);
title(caption,'FontSize', fontSize);
axis on image;
colorbar
hp = impixelinfo();
And the input and output image are attached here. Can anyone help me to segment the stone region(the white dot) from the image.
Any help is aapreciated.

回答(1 个)

Saurabh Gund
Saurabh Gund 2022-4-27
clc
clear all
close all
warning off
[filename,pathname]=uigetfile('*.*','Pick a MATLAB code file');
filename=strcat(pathname,filename);
a=imread(filename);
%subplot(3,4,1),
imshow(a);
%Convert to grayscale image
%b=rgb2gray(a);
b=im2gray(a);
%subplot(3,4,2),
imshow(b);
impixelinfo;
c=imbinarize(b,20/255);
%c=b>50;
%subplot(3,4,3),
imshow(c);
%Fill the holes in the image
d=imfill(c,'holes');
%subplot(3,4,4),
imshow(d);
%delete writings
e=bwareaopen(d,1000);
%subplot(3,4,5),
imshow(e);
PreprocessedImage=uint8(double(a).*repmat(e,[1 1 3]));
%subplot(3,4,6),
imshow(PreprocessedImage);
  1 个评论
Image Analyst
Image Analyst 2022-4-28
Here is what your code produces. Where is the kidney?
clc
clear all
close all
warning off
% [filename,pathname]=uigetfile('*.*','Pick a MATLAB code file');
filename = '\st1.png';
pathname = pwd;
filename=strcat(pathname,filename);
a=imread(filename);
%subplot(3,4,1),
imshow(a);
%Convert to grayscale image
%b=rgb2gray(a);
b=im2gray(a);
%subplot(3,4,2),
imshow(b);
impixelinfo;
c=imbinarize(b,20/255);
%c=b>50;
%subplot(3,4,3),
imshow(c);
%Fill the holes in the image
d=imfill(c,'holes');
%subplot(3,4,4),
imshow(d);
%delete writings
e=bwareaopen(d,1000);
%subplot(3,4,5),
imshow(e);
PreprocessedImage=uint8(double(a).*repmat(e,[1 1 3]));
%subplot(3,4,6),
imshow(PreprocessedImage);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by