Abstract
The medical imaging technique is used in order to obtain a tissue image of a specific part of the human body without any surgical intervention. The presence of differences in the clinical experiences of a section of doctors or doctors in general can lead to discrepancies in the analysis and understanding of medical images and thus affects the accuracy of the diagnosis for the patient’s condition. The use of a medical imaging system for reliable diagnosis through the use of the computer will lead to high accuracy in diagnosis. For this reason, the need to improve the special performance of systems that perform computer-aided diagnosis used in the medical imaging process has increased special performance of the computer-aided diagnostic systems used in the medical imaging process. The medical image classification technique has the ability to perform a preliminary analysis as well as an understanding of medical images and also can identify the affected parts of the human body, which leads to helping doctors in the process of optimal diagnosis. The process of classifying medical images needs to extract the features of the image so that the classification process is carried out with high accuracy, and one of these features is detecting the edges of the image using a Canny edge detector. This is what the author performed in the research, and the experimental results show the effectiveness and goodness of this method.
1. Introduction
It is known that the image contains important information, and when the image is processed using image-processing operations, an image will also be obtained as an output for these operations. Currently, the images used in applications are digital format images. In recent years, information technology, in addition to electronic healthcare systems, has great importance in the medical field as it helps doctors in the process of providing the best health care to patients [1]. Accurate analysis of medical images, such as detection and segmentation, as well as quantification of cancers and tumors, is of great importance for many clinical applications, which include the process of medical image retrieval as well as 3D modeling of pathology and formation of normal and abnormal molds, i.e., Atlas, diagnosis, construction, and therapy evaluation [2]. The treatment process that is applied to medical images is considered one of the nonsurgical tools of great importance and benefit for the accurate detection and diagnosis of various diseases. The methods used in the usual medical imaging process are ultrasound, X-rays, computed tomography (CT), and magnetic resonance imaging. In all of these methods, the important features of the image are extracted by using algorithms to extract the important and different features that help researchers for the early detection of these diseases, and this in turn helps in increasing the efficiency of radiologists as well as improving the diagnosis process [3]. The process of understanding as well as finding the correct part or the area of interest in the medical image will help diagnose diseases accurately and correctly. When we talk about the methods and techniques that are used in medical imaging, this means that we are talking about treatment in advance, as well as classification and segmentation, as well as extracting the features of the medical image [4]. One of the most important applications of machine learning in the field of health care is the classification of medical images. Also, using deep learning algorithms that achieve high levels of accuracy as humans do, many efforts are being made to automate diagnosis or even alarm tasks [5]. For the image classification process, the most important feature is edge detection. This paper emphasizes on the extraction of the medical image’s edges using the Canny edge detector for X-ray medical image classification. The organization of this paper is as follows: Section 2 highlights the related work. Section 3 introduces image classification. X-ray medical images are discussed in Section 4. Section 5 emphasizes on the Canny edge detector, while Section 6 produces the proposed method. Section 7 shows the experimental results, and finally, the conclusion is introduced in Section 8.
2. Related Work
In recent years, medical image classification has become a very important field for researchers, and so many different techniques have been proposed that use different features [6]. Yadav and Jadhav presented a neural network (CNN) that was applied and used on chest X-ray data in order to classify the different types of infections that can affect the human lung, and in this method, three techniques used with multiple experiments were evaluated. This classifier is a linear SVM with features of local routing-free and rotation, and the learning process of CNNs of two models [7]. Carvalho et al. introduced a new method in order to detect the COVID-19 virus by using CT scans. At first, the CNN architecture was used to obtain the features from the images of computed tomography (CT). Then, the manic parameters of the network were enhanced using the Parzen tree estimator in order to obtain and select the best parameters. After that, the (GA) genetic algorithm was used. The authors in [8] presented a method using a classifier of soft max which is a traditional classifier, and it was used with a classifier that was based on a method of transfer learning for evaluation, in order to classify tissue in cancer images within a binary dataset of breast cancer and a multiclass dataset of lung and colon cancer. In order to achieve better classification accuracy, a methodology is proposed that links the SVM classifier to the fully connected layer (FC) of the soft max-based transfer-learning model. The authors in [9] proposed an approach based on the state-of-the-art method, which is used for normalization of the color, segmentation of cell nuclei, feature selection, and classification. The authors employed an algorithm of traditional (MST) minimum spanning in order to recognize clusters and better confine the propagation and area structure of cell nuclei. Machine learning (ML) approaches based on K-medoids clustering and stacked ensemble were used to execute usual and recent AI-based classification. The classification in two types (binary and multiclass) was derived in order to evaluate the model quality and results between the grades of PC [10]. The authors introduced a method for image classification based on a hierarchical convolutional neural network (HCNN). HCNNs include multiple subnetworks that can be viewed as unusual levels of neurons in humans, which are used to classify images with time. At first, the weight of each image was initialized and each image category was used for training, and then they were used for training the first subnetwork. After that, according to the results that predicted the first subnetwork, the weights of images which were not classified are increasing, while decreasing the weights of images are classified correctly. Finally, for training the next subnetworks, the images with the updated weights are used. The same processes are performed on all subnetworks.
3. Image Classification
The process of classifying images is one of the basic and very important steps in the process of discovering the object in the image, as well as in image analysis. The output for the image classification stage may be the final output, or it may be the intermediate output. Many techniques used in image classification have been proposed so far [11]. The block diagram of the image classification is shown in Figure 1.

Figure 1 shows that the classification process depends on the similarities of items, texture, and on the description of elements. There are two methods for classifying images, the first is supervised and the other is unsupervised, and the unit representing the image is the pixel. Different image classification methods include the following operations: image acquisition, image preprocessing, image segmentation, feature extraction, and image classification. There are several methods used for classification such as the artificial neural network (ANN), support vector machine (SVM), and decision tree (DT) [12]. The image preprocessing step includes two basic steps: removing noise and then enhancing the image. For the segmentation step, which is done either depending on the intensity or colors, the image is divided into the background and the foreground. Then, features are extracted, which means reducing the size of the dataset in order to obtain the most important features, which lead to time and cost reduction [11]. Classification of images and medical illustrations aims to name medical images according to the manner in which they are produced or to name an illustration according to the production characteristics of those images. This is considered one of the difficult points in the field of mining as well as image retrieval, as the presence of a large difference within the group or category, as well as the similarity between these categories, which results due to the methods used in photography will lead to great difficulties for the problem [13].
4. X-Ray Medical Images
Medical imaging is an important and essential part of the diagnosis and treatment process. The medical images obtained will be reviewed by the radiologist, who in turn writes a report summarizing the results obtained. After that, the referring physician will determine the plan for diagnosis and treatment based on these images as well as the report submitted by the radiologist. In most cases, as part of the follow-up process, medical imaging is requested in order to verify the success of the treatment [14]. The common test that helps in evaluating various diseases is chest X-ray analysis. Also, this test can assist in finding an automated solution to the analysis in order to reduce workloads and also improve and increase efficiency as well as reduce the possibility of any error in reading. Many methods have been proposed for the treatment and detection of chest X-ray image classification [15]. The process of imaging by X-rays is through the use of these rays, i.e., “X-rays” or high-energy photons in order to take images of the structure of internal physical objects, and in medical settings, X-rays are used to take images from inside the body. Images of the body are taken through passage X-rays directly through the solid matter, and then, they are absorbed into electron clouds around atoms. Thus, a person can look at the X-ray image by seeing a “density map” of electrons, and this is effectively related to the place where soft tissues and bones are present in the body [16]. In 1895, the first X-ray imaging of small animals was reported. In this method, an imaging technique is used through which radiation is used in order to produce images of bones and tissues of organs. It is the most common clinical examination as it is widely used by a radiologist in order to diagnose lung diseases, and by passing an X-ray beam through the body, a chest X-ray is performed. This process is carried out through two methods: the first method is posterior-anterior (PA), in which the ray beam is passed from the back to the front and the second method is anterior-posterior (AP), in which the ray beam is passed from the front to the back. The image is shown in black and white, depending on the absorption of these X-rays, due to different density of the parts of the body, where the air in the lungs appears in black, due to its low density. Chest X-ray imaging uses the rib cage, lungs, heart, airways, and blood vessels. It is a very common diagnosis of tuberculosis, pneumonia, pulmonary nodules, as well as scarring of lung tissue called fibrosis [17].
5. Canny Edge Detector
The algorithm of Canny operator edge detection smooths the image at the first stage by using a Gaussian filter, and at the second stage, the amplitude with the direction of the gradient must be suppressed by the maximum. At the third stage, in order to detect and connect the edges, the algorithm of double threshold is used. The block diagram for these stages is shown in Figure 2.

Canny operator edge detection tries to find the local maximum of the gradient amplitude. In order to calculate the gradient, the derivative of the Gaussian filter is used. To detect the strong edge and the weak edge, respectively, the Canny operator uses two thresholds [18]. The traditional algorithm of Canny edge detection is used in grayscale images as this algorithm is not able to deal with color images, so there is great difficulty in determining parameters adaptively [19]. The idea of the algorithm of Canny edge detection is divided into the flowing steps.
5.1. Step 1: Gaussian Smoothing
The use of the Gaussian function in this step is very important for the classical algorithm of Canny edge detection as images are smoothed in order to remove noise before beginning the edge detection process. The classic Canny edge detection algorithm uses one dimension of the Gaussian function in order to smooth images as well as remove noise from them. The image function is a grayscale image. The rows and columns for this image are convoluted separately. Then, the filtered image is obtained [20]:where σ is the standard deviation (size) of the Gaussian filter used to control the degree of smoothing, so σ plays an important role in the process of image edge detection.
5.2. Step 2: Gradient Magnitude
In order to obtain the gradient magnitude of the smoothed image and its direction, it is important to find the partial derivative. For this process, a neighborhood of the first-order partial derivative of the image for the -direction and -direction difference operations can be obtained as follows:
The pixel’s gradient magnitude and direction can be calculated using the equations:
5.3. Step 3: Nonmaxima Suppression of the Gradient
The point of the local maximum gradient must be retained, which enables it to determine the edge in a better way.
5.4. Step 4: Double-Threshold Detection and Edge Connection
At first, the upper threshold will be determined (Th) and the lower threshold (Tl), where (Tl = 0.6 Th), and then, it will be determined whether this point is an edge or not. If the amplitude of the gradient of this pixel point is less than the low threshold value, then this point is not considered an edge. However, if the amplitude of the gradient of this pixel point is greater than the high threshold value, then this point is considered an edge [21].
6. Materials and Methods
The proposed method for using Canny edge detection for X-ray lung medical image classification consists of several stages. The color image is read from a database that has several medical images collected from the web; then, these images are resized into smaller sizes in order to facilitate the process, and color images are converted to grayscale images. After that, a binary image is obtained, and in order to remove noise from the image, a median filter is used. Finally, a Canny edge detector is applied. The general structure of the proposed method is shown in Figure 3.

6.1. Image Database
A database containing six (X-ray lung) medical images with different sizes is used for the proposed method as shown in Figure 4. These images were collected from the web, and they are real images of the lungs affected with cancer.

6.2. Image Resizing
At first, the X-ray medical image reading from the database must be resizing in order to reduce the time needed to process. In this proposed method, the image was resized to (200 × 200) pixels.
6.3. RGB Image Conversion
The colored medical image is converted to a grayscale image by using the following equation:
6.4. Global Thresholding
The grayscale image is converted into another form (binary image), using the Otsu’s method which perform a histogram shape-based image thresholding or transform the grayscale image into binary form. In this method, the image is considered to have two classes of pixels: foreground and background, and after that, the optimum threshold is calculated in order to separate these two classes, which result in their minimal combined spread (intraclass variance) [19].
6.5. Median Filter
The image resulting from the previous step (binary image) may have some kinds of noise, which make some problems in the process of edge detection, so a median filter with a size of (3 × 3) is used. In order to calculate the median, all pixel values will be sorted from the bordering neighborhood into numerical order, and after that, the value of the given pixel will be replaced with the value of the middle pixel. If the given neighborhood contains an even amount of pixels, then the mean of the two middle pixel values will be used. The MATLAB code for implementing the median filter is shown in Figure 5.

6.6. Canny Edge Detector
The algorithm of Canny edge detection had, at first, the underdone image convolved with a Gaussian filter, and this step is for reducing the noise. After that, two filters are used: one used for horizontal direction and the other for vertical direction. These filters are used for computing the gradient. Finally, the gradient’s magnitude and orientation are calculated using a simple threshold technique that suppresses the edges with a low value [19].
7. Experimental Results
All experiments for the proposed method are performed using MATLAB software on the Windows 8 platform. First, the input color image is read from the database, and after that, it is converted into a grayscale type, as shown in Figure 6.

In order to obtain a binary image from the grayscale image, the algorithm of global thresholding is applied, and this process is presented in Figure 7.

The binary image may have some noise, which must be removed, so a median filter with a (3 × 3) size is used for this purpose, as shown in Figure 8.

Finally, the Canny edge detector is used to extract the shape feature of the medical image in order to use this feature in the poststage (classification). Figure 9 shows the resulting image after using the Canny edge detector:

All previous operations were performed on all X-ray lung medical images in the database, and the following results were obtained as shown in Figure 10.

The Canny edge detection operator has very good performance in detecting the edges of medical images. Table 1 shows a comparison between advantage and disadvantage of this operator.
8. Conclusion
Classification of X-ray medical images is a process of great importance in order to support the decision that is taken by doctors, which is based on the images of the body’s structures and internal tissues of the patient. The number of images that are taken for each patient is increasing with the passage of time, so there is an urgent need to make accurate systems that automatically classify medical images, as manual classification is prone to error and also takes a long period of time. So an accurate feature must be used for the classification process. In this paper, an approach for extracting the shape of the X-ray lung medical image is proposed by using Canny edge detection since it is the most favorable and broadly used method in research as an edge detection technique, which is considered to be a very good candidate algorithm for medical image classification because its performance has high generalization.
Data Availability
The images of the database for this research are collected from the web.
Conflicts of Interest
The author declares no conflicts of interest regarding the present study.
Acknowledgments
The author would like to thank all the researchers whose experiences are benefited for the sake of continuous learning and thus benefit future generations.