Can anyone help me to segment the stone from the kidney image
3 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Saurabh Gund
on 27 Apr 2022
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 Comment
Image Analyst
on 28 Apr 2022
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);
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!