I want to extract the disease area of the teeth image attached

27 views (last 30 days)
i attach the two images one the original images and the other one is the desired results image, i am confusing how to do this because disease part and same intensity pixels exist(bottom center) in the images but i just want to highlight or segmented out only the disease part from the teeth x-ray image. Your help highly appreciated. Many Thanks
  1 Comment
Saptadeepa Kalita
Saptadeepa Kalita on 23 Sep 2020
I am working on the same topic. I need some assistance. Please reply if you can. Infact I m looking for a good collaboration. Please reply if you can help. (saptadeepakalita@gmail.com)

Sign in to comment.

Answers (3)

Image Analyst
Image Analyst on 12 Jul 2017
What are you willing to assume? Like dark but nonzero caries pixels are in the bottom half of the image? And/or that they must be in a certain size range? How is the algorithm supposed to know that you don't have one enormous carie in the bottom middle of the tooth (in addition to the two small ones on the sides)?
  5 Comments
Saptadeepa Kalita
Saptadeepa Kalita on 23 Sep 2020
@image analyst can you help me with rvg xrays! I would be thankful to you

Sign in to comment.


Image Analyst
Image Analyst on 21 Jun 2020
Try this:
% Demo to find cavities in teeth.
% By Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 22;
%--------------------------------------------------------------------------------------------------------
% READ IN IMAGE
folder = pwd;
baseFileName = 'orignal_image.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% The file doesn't exist -- didn't find it there in that folder.
% Check the entire search path (other folders) for the file by stripping off the folder.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
grayImage = rgb2gray(grayImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
% grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the image.
subplot(2, 4, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
hFig = gcf;
hFig.WindowState = 'maximized'; % May not work in earlier versions of MATLAB.
drawnow;
%--------------------------------------------------------------------------------------------------------
% HISTOGRAM OF IMAGE
subplot(2, 4, 2);
imhist(grayImage)
grid on;
title('Histogram of Entire Tooth', 'FontSize', fontSize, 'Interpreter', 'None');
%--------------------------------------------------------------------------------------------------------
% SEGMENTATION OF IMAGE
% Get a binary image
binaryImage = imbinarize(grayImage);
subplot(2, 4, 3);
imshow(binaryImage, []);
impixelinfo;
title('Binary Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
% Fill image
binaryImage = imfill(binaryImage, 'holes');
% Take largest blob
binaryImage = bwareafilt(binaryImage, 1);
% Erase root of tooth
binaryImage(1:200, :) = false;
% Get histogram within the masked area alone.
subplot(2, 4, 4);
histogram(grayImage(binaryImage), 256);
grid on;
title('Histogram of Crown of Tooth', 'FontSize', fontSize, 'Interpreter', 'None');
xline(185, 'Color', 'r', 'LineWidth', 2);
% Threshold again at 185
cariesMask = grayImage < 185 & binaryImage;
subplot(2, 4, 5);
imshow(cariesMask, []);
impixelinfo;
title('Caries', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
% Erode the image.
cariesMask = imerode(cariesMask, true(5));
subplot(2, 4, 6);
imshow(cariesMask, []);
impixelinfo;
title('Potential Caries', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
% Find centroids so we can delete any blobs near the middle.
[labeledImage, numBlobs] = bwlabel(cariesMask);
props = regionprops(labeledImage, 'Centroid', 'Area');
allAreas = [props.Area]
blobsToKeep = true(numBlobs, 1);
for k = 1 : numBlobs
x = props(k).Centroid(1);
if abs(x - columns/2) < 30
blobsToKeep(k) = false; % Ignore blobs near the middle.
end
end
% Get new cariesMask
cariesMask = ismember(labeledImage, find(blobsToKeep));
% Extract blobs only that are bigger than 100 pixels.
cariesMask = bwareaopen(cariesMask, 100);
% Dilate back out to original size.
cariesMask = imdilate(cariesMask, true(5));
% Display image.
subplot(2, 4, 6);
imshow(cariesMask, []);
impixelinfo;
title('Caries', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
% Get boundaries
boundaries = bwboundaries(cariesMask);
% Display over original image.
subplot(2, 4, 7);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize, 'Interpreter', 'None');
impixelinfo;
hold on;
for k = 1 : length(boundaries)
thisBoundary = boundaries{k};
x = thisBoundary(:, 2);
y = thisBoundary(:, 1);
plot(x, y, 'r-', 'LineWidth', 3);
end
  4 Comments
Mohamed AlAli
Mohamed AlAli on 7 Nov 2021
this is amazing, but im trying it with other pictures and its not working. how can i train a dataset using this code can you help me with that?
Image Analyst
Image Analyst on 7 Nov 2021
@Jahanzeb Saqib, it looks like it worked, so could you please "Accept this answer"? Thanks in advance.

Sign in to comment.


Abdelaziz AlAli
Abdelaziz AlAli on 7 Nov 2021
thank you, we tried with other images it didn't work

Community Treasure Hunt

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

Start Hunting!