Intelligent system for detecting tooth decay in OPG images by image processing

Sanaz Rouhparvar1*; Ahmad Reza Mohammadi Samani2

1. Department of Computer Engineering, Shandiz Institute of Higher Education, Mashhad, Iran, 2. Department of Computer Engineering - Kashan Branch, Islamic Azad University, Kashan, Iran

Correspondence: *. Corresponding author: Sanaz Rouhparvar


Introduction: Dental caries and lesions are one of the most common dental diseases worldwide, affecting a high percentage of the world's population. Research has shown that more than 90% of adults have experienced tooth decay, so early detection of dental lesions in the early stages is a major aspect of maintaining dental health.

Material and Methods: In order to diagnose decayed teeth, first, the difference between decayed teeth and healthy teeth was discussed. By first calling the OPG images and removing the inappropriate margins of the image. Then the gray-scale image was converted to binary and after removing the noise, thresholding was performed. Then we found the location of the white spots in the black image and displayed the processed image on the user interface.

Results: Computer image processing systems have been developed to be able to process and analyze images with better speed and accuracy. The proposed system has a good performance in diagnosing dental caries and the results show that the proposed system is reliable and optimal and as a clinical decision support system can help dentists in accurate and early diagnosis of dental caries at the initial level of caries.

Conclusion: In this article, using the advancement of technology that has been formed in recent years, we were able to provide a solution to facilitate medical science. With the science of image processing, eye errors that may cause problems during the diagnosis and recording of the disease in the process of recovery are significantly reduced.

Received: 2022 January 24; Accepted: 2022 February 9

FHD. 2022 Feb 13; 10(1): 105
doi: 10.30699/fhi.v11i1.358

Keywords: Key Words Image Processing, Tooth Decay, OPG Images, OpenCv.


Tooth decay is one of the most common diseases that most people suffer from throughout their lives [1]. Early detection and diagnosis of caries is essential to maintain tooth tissue and maintain oral health [2]. One of the best ways to diagnose this disease is radiographic images [3]. Tooth decay can also be detected by visual and tactile examination, laser fluorescence [2], measurement of tooth electrical resistance [4] and optical fiber [5]. The advantages of panoramic or OPG radiography are very high image quality and faster and easier to use compared to conventional methods. Also, this imaging method requires a lower dose of radiation and the absence of chemicals in imaging are other advantages of this method [6-9].

Diagnosis of tooth decay in the early stages is important because non-invasive methods can prevent the disease process and reduce the cost of health and care of the patient.

Diagnosing different degrees of tooth decay is a difficult task that dentists can overcome with skill and experience. On the other hand, some mild caries cannot be detected by a doctor, and considering this issue, the use of new technologies can help dentists to accelerate the diagnosis of mild caries [10-12].

In this article, we present a system that, after receiving and reading gray-scale images, converts them to binary, and after setting the threshold, considers the white dots and parts found in the black image as rotten dots. And then measures stains and parts and shows decayed teeth. Attempts have also been made to provide an intelligent system using image processing to be able to detect mild caries early and to prevent further lesions and caries of the tooth [12-15].

Caries is one of the most common and preventable diseases worldwide. Finding a way to diagnose mild dental caries, which is very common, is very important because early detection of mild caries can prevent the process of caries with non-invasive methods such as improving oral hygiene, reducing dietary sugar and using fluoride [16-18]. In the following, we will review some of the best articles in this field.


In this article, in order to diagnose decayed teeth, first the difference between decayed teeth and healthy teeth was discussed. In this way, the image was read and the inappropriate margins of the image were removed. Then we set a threshold for converting gray-scale images to binary on images. Then we found the location of the white spots in the black image and displayed the processed image on the user interface. This method uses OPG images and shows the exact location of tooth decay. In the Fig 1, we show the general process of the proposed method.

[Figure ID: F1] Fig 1. The general process of the proposed method

In this study, to diagnose decayed teeth, first after pre-processing and eliminating noise and improving image quality, we will distinguish between decayed teeth and healthy teeth. Decayed teeth in the image are whiter than healthy teeth. Now, with this distinction, we can easily see that for the initial diagnosis of decayed teeth, it is enough to keep the white spots and remove the rest of the image. After thresholding, the whole image is blackened and only the desired parts or the same decayed teeth remain. Now we need to find the location of decayed teeth. To do this, it is enough to find the location of white spots in the image of Threshold. To do this, we use the find Contours command. This command helps us to find the location of white spots in the image, and then we can highlight the location of decayed teeth or white spots and count the number of decayed teeth and display in the user interface. Let. In the picture below, we can see the difference between healthy teeth and decayed teeth.

The method was to first read the images in OpenCV by creating a window and then by uploading and displaying the image. To display the image, we used a string command whose first argument actually specifies the name of the window and the second argument shows how the window is displayed (Fig 2).

[Figure ID: F2] Fig 2. Distinction of healthy and decayed teeth

The OpenCV image is then read by the cvLoadImage command, whose function is a string that specifies the path of the image and an integer value that specifies how the black-and-white or color image is loaded.

The cvShowImage command is then used to display the image, and this command contains a string containing the name of the window in which the image should be displayed, and its second argument, a variable that is the same as the image to be displayed in Come on. The image was then written to OpenCV using the cvSaveImage command.

After calling the image, we removed the inappropriate margin from the image. Then, in order to improve the image, we sought to remove noise from the images, because in opg shooting, the presence of shadows during shooting causes the presence of noise and reduces the image quality. We used [18] 2D-Adaptive Consensual Filter to remove noise. Using this filter, in addition to smoothing the images, also reduces the image contrast between one pixel and the next pixel, and finally the average intensity intensity of the pixels is taken.

In image thresholding, we want to divide the pixels of an image into two groups in terms of brightness and get a binary image whose pixel values ​​are zero and one. Therefore, to convert a gray-scale image to a binary image, we set a threshold that set all pixels with a value below the threshold to 0 and all pixels with a value above the threshold to 1.

This operation is also implemented in OpenCV, and if the pixel value is greater than the threshold value, a value is assigned to it (it may be white), otherwise another value is assigned to it (possible It must be black).

The function used in OpenCV for thresholding is cv2.threshold. The first parameter is the source image, which should be a gray-scale image. The second parameter is the threshold value, which is used to classify pixel values.

The third parameter is the maximum value (Max value), which indicates the value that if a pixel is greater than the threshold value, the Max value is assigned to that value.

And is the minimum value (Min value), which indicates the value that if a pixel is less than the threshold value (threshold value), the Min value is assigned to that value.

The fourth parameter is related to type, and OpenCV has specified different modes for thresholding, which we have used cv2.THRESH_BINARY.

The Fig 3 shows the output after thresholding.

[Figure ID: F3] Fig 3. Output after threshold

Then we found the location of the white spots in the black image (Fig 4).

[Figure ID: F4] Fig 4. Find the location of white spots in the black image

And then we measured the spots and with the help of testing and conditioning, spots smaller than 10 and bigger than 150 were removed from our image. By getting white spots in the image and dragging the box around the decayed teeth, we were able to determine the number of decayed teeth in the image and display it on the user interface (Fig 5).


In this study, 200 OPG images from the radiology of Dr. Seyed Hossein Hosseini Zarch were collected and examined, which included women and men in the age group of 28 to 65 years.

Also, all the implementation steps have been done using Matlab R2016b software and opencv library on AMD Quad Core FX-8800P up to 3.4 GHz processor with 8 GB of memory. We have also used Visual Basic to define and implement the user interface, because easy and fast access to databases is one of the things that encourages users to use this programming language.

[Figure ID: F5] Fig 5. Display the processed image on the user interface

The proposed method is evaluated from four perspectives.

Accuracy: Determines how successful the proposed system has been in detecting.

TP + TN TP + TN + FN + FP (1)

Sensitivity: Determines how well the proposed system has correctly detected decayed teeth.

TP TP + FN (2)

Specificity: Determines how well the proposed system has correctly identified healthy teeth.

TN TN + FP (3)

ROC Graph: Another important criterion that we used to determine the efficiency of the proposed system is the Area Under Curve (AUC) standard. The AUC indicates the ROC (Receiver Operating Characteristic) level. ROC curves are actually two-dimensional curves in which the True Positive Rate (TPR) is plotted on the Y axis and the False Positive Rate (FPR) curve is plotted on the X axis. The basis of the following formula is calculated.

TPR rate= TP TP + FN TP (4)

FPR rate= FP FP + TN FP (5)

True Positive (TP): A decayed tooth can be properly identified as decayed.

False Positive FP (False Positive): A healthy tooth is misdiagnosed as decayed.

True Negative TN: A healthy, properly identified tooth.

False Negative FN: False teeth, misdiagnosed as healthy.

In the proposed method, the data set is divided into K equal parts using the K-Fold Cross Validation method. The K-1 part is used as a training data set and the model is built based on it and the evaluation operation is performed with the remaining part which is considered as a test set. This process will be repeated K times. Each time an accuracy is obtained for the model. In this method of accuracy evaluation and other measurement parameters are calculated equal to the average K. In our method, we examined the results by considering (K = 10). In the proposed method for examining the model, the data were divided into two categories of training 70 percent and experiments 30 percent. The data of the training section builds the model and the data of the experimental section evaluates the created model. The answer is the mean K = 10 on the test dataset. According to the set evaluation parameters, the results of the proposed algorithm are measured in MATLAB software and are shown in Table 1.

Table 1. Evaluation results of the presented model
98.3% Accuracy
97.9% Sensitivity
98.1% Specificity
2 Wrong detection
1 False negative
1 False positive
60 N ts

The number of test data is 30% of the image set represented by the Nts parameter. The first parameter, which is accuracy, is the most important criterion for determining the efficiency of the proposed method, which shows that the designed method correctly detects what percentage of the total experimental data set, which according to Table 1 in our proposed method was 98.3%. . The second parameter is sensitivity, which the proposed method correctly evaluates 97.9% of dental caries. The third parameter, namely the specificity of the ratio of the number of healthy teeth detected to the total number of healthy teeth, was calculated to be 98.1%.

Due to the fact that the accuracy of the model alone is not a sufficient criterion for model evaluation, in the present study, rock curve analysis, which is one of the best criteria for model evaluation, was used. Fig 6 shows the proposed method ROC diagram. The X-axis is a property (True negative rate) means the ratio of negatives that the model correctly identifies as negative, and the Y-axis is the sensitivity (True positive rate) means the ratio of positive items that the model models. Correctly recognizes as positive. After running the model 30 times, the AUC (area below the curve) was 0.942 and the number obtained indicates that the proposed model is an acceptable model with high performance.

[Figure ID: F6] Fig 6. ROC diagram of the proposed method


In one study, researchers developed a new approach to automatically detecting teeth and classifying dental problems using panoramic X-ray images. They collected panoramic radiographs from three dental clinics. Then, using image processing and image segmentation and deep neural network training, they were able to diagnose tooth decay [3].

In another study [6], researchers used post-diffusion artificial neural networks to analyze X-ray images of patients' teeth. They considered the coefficients of pixel autocorrelation as input feature vectors and found that decayed teeth have an uneven density distribution compared to healthy teeth.

In another study [7], researchers used a deep torsional neural network system with more than 100 layers to learn the work of densely classifying dental cavities on bite-wing radiography. They also obtained a threshold for classifying a pixel as zero or one from the results of a training set, using only five percent of the set of images for testing, and were able to provide a system that would automatically detect tooth decay on radiography. Finds byte wing.

In a study [1], researchers have developed a method that uses various pre-trained deep learning models through transmission learning to extract related features from X-rays and uses a capsule grid to plot prediction results. And increase the speed of caries detection, and due to the accuracy of their detection, they concluded that among the images with caries lesions in the experimental set, their model detects areas with severe caries with high accuracy and the detection of mild caries in a larger data set. needs.

While taking a panoramic dental radiograph can be very helpful in seeing a complete patient's tooth in an image, diagnosing tooth decay using panoramic dental images is a very challenging task due to the poor image quality and the ambiguity of the caries areas.

Some researchers [8] have also used meta-heuristic algorithms to increase the accuracy of dental caries detection. They performed feature extraction using the Adaptive Dragonfly (DA) algorithm and then classified the images using a neural network (NN) and were able to improve the accuracy of dental caries detection.

In another study [9], researchers performed feature extraction based on multi-linear principal component analysis (MPCA) and then classified the images using a neural network (NN) and were able to improve the accuracy of dental caries diagnosis.

In a study [10], researchers developed a method to diagnose tooth decay using x-ray images. They used a deep neural network with the AlexNet architecture

Researchers [11] have proposed a way to improve the diagnosis of caries in order to facilitate the detection of tooth decay in X-ray panoramic images. In this way, after receiving images and pre-processing using cropping, they used the method of multiple morphological gradients.

In another study [12], researchers developed a method of detecting semi-automatic caries using image processing and segmentation using the SVM method and were able to detect caries in images.

In another study, researchers [13] developed a method for automatically detecting tooth decay. They developed an algorithm for detecting and determining caries lesions in the early stages. They used the multiple morphological gradient method, which produces high-resolution images and identifies the edges of objects in the image. Showed the severity of caries

In a study [14], researchers have developed a system for detecting tooth decay that captures the input image from the user. In this input image, the user has manually marked the area containing the decay. The system then calculates the average gray values ​​of the pixels in the marked area and compares the color of each pixel in the image with the Euclidean distance measure, with the average value obtained. It then detects decayed teeth based on the similarity of the pixels.

In another study [15], researchers used discrete two-dimensional wavelet transform. In this way, they found the conversion coefficients to separate the frequency of the tooth from the X-ray image, and then they were able to detect the decayed tooth.

Researchers have also used SVM to diagnose tooth decay in a study [16] and after reviewing and comparing it with the neural network method, they concluded that svm performs better than the neural network and the dentist's own diagnosis.

In one of the best works done in recent years [17], researchers performed preprocessing to even out the level and brightness and contrast of dental images with a comparative approach. They also used diagram section dividers to divide the background and background of dental X-ray images and used a deep neural network to predict dental images.


The most important issue in preventing severe tooth decay is early detection and early stages to prevent further problems. In this study, an intelligent system using X-ray panoramic image processing is presented, which helps physicians in early detection of dental caries in the early stages, and using the advancement of technology that has been formed in recent years, we were able to find a solution to Facilitate medical science. Therefore, the main purpose of this study is to achieve high accuracy in the field of early detection of dental caries. To achieve this goal, various algorithms and many works have been done to date. But there is still work to be done to increase the accuracy and early detection of tooth decay. To solve these problems in this study, we first called the images and after pre-processing and setting the threshold, we were able to identify decayed teeth in the black image and draw a line around them and display them on the user interface. According to the results, we found that the proposed system has a good performance in diagnosing dental caries. The results show that the proposed system is reliable and optimal and as a clinical decision support system can help dentists in accurate and early diagnosis of dental caries.

1. Haghanifar, A. Majdabadi, MM. Ko, SB. PaXNet: Dental caries detection in panoramic X-ray using ensemble transfer learning and capsule classifier [Internet].
2. Walsh, T. Macey, R. Riley, P. Glenny, AM. Schwendicke, F. Worthington, HV. Imaging modalities to inform the detection and diagnosis of early caries. Cochrane Database Syst Rev. 2021 3(3)
3. Muresan, MP. Barbura, AR. Nedevschi, S. Teeth detection and dental problem classification in panoramic X-ray images using deep learning and image processing techniques. International Conference on Intelligent Computer Communication and Processing (ICCP). IEEE
4. Macey, R. Walsh, T. Riley, P. Glenny, AM. Worthington, HV. Clarkson, JE. Electrical conductance for the detection of dental caries. Cochrane Database Syst Rev. 2021 3(3)
5. Benjumea, E. Diaz, L. Torres, C. Tooth decay detection using a fiber optic sensor. Rev Fac Odontol Univ Antioq. 2018 29(2):405–20.
6. Akkaya, N. Kansu, Ö. Kansu, H. Çaǧirankaya, LB. Arslan, U. Comparing the accuracy of panoramic and intraoral radiography in the diagnosis of proximal caries. Dentomaxillofacial Radiol. 2006 35(3)
7. Srivastava, MM. Kumar, P. Pradhan, L. Varadarajan, S. Detection of tooth caries in bitewing radiographs using deep learning [Internet].
8. Patil, S. Kulkarni, V. Bhise, A. Algorithmic analysis for dental caries detection using an adaptive neural network architecture. Heliyon. 2019 5(5)
9. Patil, S. Kulkarni, V. Bhise, A. Intelligent system with dragonfly optimisation for caries detection. IET Image Process. 2019 13
10. Oliveira, J. Proença, H. Caries detection in panoramic dental X-ray images. In: ManuelJ, Tavares RS, Natal Jorge RM (eds). Computational vision and medical image processing. Springer
11. Na’am, J. Harlan, J. Madenda, S. Wibowo, EP. Image processing of panoramic dental X-ray for identifying proximal caries. Telkomnika (Telecommunication Comput. Electron. Control). 2017 15(2)
12. Li, S. Fevens, T. Krzyzak, A. Jin, C. Li, S. Semi-automatic computer aided lesion detection in dental X-rays using variational level set. Pattern Recognition. 2007 40(10)
13. Yan, J. Xiang, Y. Jian, X. Automated detection and quantification of early caries lesions on images captured by intraoral camera. International Symposium on Bioelectronics and Bioinformations. IEEE
14. Olsen, GF. Brilliant, SS. Primeaux, D. Najarian, K. An image-processing enabled dental caries detection system. International Conference on Complex Medical Engineering. IEEE
15. Patanachai, N. Covavisaruch N, Sinthanayothin C. Wavelet transformation for dental X-ray radiographs segmentation technique. International Conference on ICT and Knowledge Engineering. IEEE
16. Kuang, W. Ye, W. A kernel-modified SVM based computer-aided diagnosis system in initial caries. International Symposium on Intelligent Information Technology Application. IEEE
17. Lakshmi, MM. Chitra, P. Tooth decay prediction and classification from X-ray images using deep CNN. International Conference on Communication and Signal Processing. IEEE
18. Ramana, TV. Nandhagopal, SM. Alzheimer disease detection and classification on magnetic resonance imaging (MRI) brain images using improved expectation maximization (IEM) and convolutional neural network (CNN). Turkish Journal of Computer and Mathematics Education. 2021 12(11)


  • There are currently no refbacks.