Abstract
Foods are very essential for living beings for providing energy, development and preserve their existence. It plays a vital role in promoting health and preventing illness. Nowadays, many people are suffered from obesity, they tend to maintain their body weight by consuming a sufficient number of calories in their routine life. In this research, a novel Modified Deep Learning-based Food Item Classification (MDEEPFIC) approach has been proposed to categorize the different food items from the dataset with their calorie values. Initially, the images are processed using the sigmoid stretching method to enhance the image quality and remove the noises. Consequently, the pre-processed images are segmented using Improved Watershed Segmentation (IWS2) algorithm. Recurrent Neural Network (RNN) is used to extract features like shape, size, textures, and color. The extracted features are then normalized using the modified dragonfly technique for same food calorie calculation. Bidirectional Long Short-Term Memory (Bi-LSTM) is utilized to classify food products based on these pertinent aspects. Finally, using food area volume and calorie and nutrition measures based on mass value, the calorie value of the categorized food item is calculated. The efficiency of the proposed method was calculated in terms of specificity, precision, accuracy, and recall F-measure. The proposed method improves the overall accuracy of 4.99%, 8.72%, and 10.4% better than existing Deep Convolution Neural Network (DCNN), Faster Recurrent convolution neural network (FRCNN), Local Variation Segmentation based Support Vector Machine (LSV-SVM) method respectively.
Keywords
Introduction
Overweight and obesity are defined as an abnormal or excessive deposit of fat that is harmful to one’s health. [1]. Physical activity [2], calorie consumption that is too high, and hereditary factors are all major contributors to obesity [3, 4]. Dietary evaluation is now exceedingly challenging and largely rely on patient self-reported data [5]. The dietary evaluation typically entails many processes, including segmentation [6], recognition [7], weight calculation, and mass calculation [8, 9].
Calories are essential in determining how much energy is consumed by our bodies [10]. According to recent study, obese people are more likely to experience serious health issues like high blood pressure, cardiac arrest, type 2 diabetes, high blood cholesterol, breast and colon cancer, and breathing difficulties [11]. The patient is required to keep a daily food diary as part of obesity therapy, but most patients difficulties to quantify or manage their intake since they are malnourished and lack self-control [12].
Obesity prevalence and central obesity vary from 11.7 to 32.1 percent and 17 to 36.4 percent, respectively, as per the Indian Council of medical research [13]. The Journal Lancet conveys that the survey of 2018, India got the third rank in obesity. Early prevention of obesity means, people must take a balanced number of calories, nutrients, carbohydrates and do some physical activities and exercises [14]. A lot of techniques are involved to identify the number of calories, carbohydrates, and nutrients [15]. However, most of these systems have flaws, such as difficulty in using them or huge computation mistakes. Moreover, the existing techniques have some limitations such as low computational time and misclassification and this leads to get the error values of the measuring calories. To overcome this challenge, a novel Deep Learning-based Food Item Classification (MDEEPFIC) approach has been proposed to categorize the different food items from the dataset with their calorie values. Initially, the images are processed using the sigmoid stretching method to enhance the image quality and remove the noises. Consequently, the pre-processed images are segmented using Improved Watershed Segmentation (IWS2) algorithm. A recurrent neural network (RNN) is utilized to extract characteristics like shape, size, textures, and color. The extracted features are then normalized using the modified dragonfly technique for same food calorie calculation. Based on these relevant features the Bi-LSTM is used to classify the food items. Finally, using food area volume and calorie and nutrition measures based on mass value, the calorie value of the categorized food item is calculated.
The remainder of the paper is arranged as follows. The literature review is summarized in Section 2, followed by a discussion of the proposed model and related algorithms in Section 3, then a performance analysis and protocol comparison of the suggested method in explained Section 4. Section 5 encloses with conclusion.
Related works
This section provides an overview of certain machine or deep learning-based algorithms for food image processing. Some of those techniques are illustrated briefly in this section.
In 2017 Minija et al., [16] proposed a classification of food images using a sphere-structured support vector machine. The segmented food items are classified by employing Sphere Shaped SVM classifiers based on an FCM algorithm. Calorie values are calculated automatically by identifying food items and calculating their nutritional values. Based on the proposed method, 95% of accuracy is achieved, which proves to be better in terms of classification.
In 2021 Manjunathan et al., [17] proposed a faster deep-learning algorithm for segmentation and calculating the calorie and nutrition content. Here, the histogram equalization method is utilized to enhance the pixel brightness. Next, the histograms of oriented gradients and local binary patterns are used to extract the features based on size, shape, and color. The goal of this work presents a feasible method for patients and nutritionists to compute and manage daily food consumption but, the processing speed is low.
In 2017 Kohila et al., [18] developed a fuzzy c-means algorithm was including segmentation for extracting image features have been used as a morphological technique. The standard deviation, mean, area, volume, variance, and density are the features retrieved in this technique, which will assist in the determination of calorific value. Here, this technique was not suitable to implement the smartphone application for calculating the calorie content of a variety of meals.
In 2017 Farooq et al., [19] developed a convolution neural network (CNN) for extracting the features from the food images. The images are collected from the Pittsburgh fast-food image database for training linear support vector machine (SVM) was utilized. For classification, features from three separate fully connected layers of convolution neural network (CNN) were employed. It secures poor accuracy and it processed only a small number of datasets.
In 2019 Wasif et al., [20] put forward to faster RCNN (F-RCNN) used for detection, and the grab-cut algorithm is used for segmentation and feature extraction. After that, the probing object is used to calculate the known volume by determining the volume of the food items. In this case, the link between mass and calories is used to compute the calories in the food items. After then, the volume is used to determine the calories in the food item, however, this process is highly complex.
In 2017 Minija et al., [21] developed a neural network classifier for classification and measuring calories. The segmentation procedure includes both quick rejection and multi-scale segmentation. Following the extraction of the characteristics, a feed-forward neural network is utilized to detect the segmented area. The proposed method’s results are 96% accurate, which results in superior classification performance.
In 2020 Latif et al., [22] put forward a deep convolution neural network (DCNN) for determining the automated fruit calories. The goal of this paper is to develop an app that can virtually provide an accurate assessment of the calories in fruits and vegetables particularly. People of various age groups will be able to use the applications. While using this application, the internet is not necessary. Here, it is cost-effective and the operating speed is slow.
In 2021 Deshmukh et al. [23] presented a calorie calculation utilizing a machine learning method. The suggested method is carried out in three stages: first, Faster R-CNN is used to identify the item, then the Grab algorithm is used to segment it. After segmenting the food product, they measure its volume. Finally, we calculate the food item’s calories.
In 2019, Sukvichai, K., et al. [24] proposed an easy way to determine nutrition by using Convolutional Neural Network (CNN). YOLO v3 network is chosen as the classifier and localizer for ingredients, and the Mobile Net network is chosen as the food categorization network. Although performance is extremely poor, the network can classify food, identify ingredients, and locate them with at least 80% accuracy.
In 2018 Minija et al., [25] developed a local variation segmentation (LVS) based multi kernel based SVM (LVS-SVM) in image processing for detection and segmentation. This paper also suggests a nutritional evaluation method to assist users and nutritionists in determining and maintaining healthy eating habits in everyday life. It increases categorization accuracy and aids in calorie value calculation.
The main drawbacks identified with the prior methodologies are poor accuracy, wide variability in calorie amounts, misclassification, and database sets with few entries. The proposed method employs a classification strategy with a novel Modified Deep Learning-based Modified Food Item Classification (MDEEPFIC) approach to overcome these drawbacks.
Proposed MDEEPFIC methodology
In this section, a novel Modified Deep Learning based Food Item Classification (MDEEPFIC) approach has been proposed to categorize the different food items from the dataset with their calorie values. Initially, the images are processed using the sigmoid stretching method to enhance the image quality and remove the noises. Consequently, the pre-processed images are segmented using Improved Watershed Segmentation (IWS2) algorithm. Recurrent Neural Network (RNN) is utilized to extract features like shape, size, textures, and color. The extracted features are then normalized using the modified dragonfly technique for same food calorie calculation. The Bi-LSTM is utilized to categorize the food items based on these relevant features. Finally, using I food area volume and (ii) calorie and nutrition measures based on mass value, the calorie value of the categorized food item is calculated. The architectural structure of the proposed technique is shown in Fig. 1.

Overall block of MDEEPFIC framework.
In this research, the dataset from [22] has taken; Twenty different types of fruits and vegetables, total of 20 varieties, make up the dataset used in this study. 8 classes for fruits and 8 classes for vegetables make up the 16 separate categories into which the data is divided. The five fruits and vegetables distributed to each class are different. Some classes, though, only include a combination of 4 fruits or vegetables. On various sized, shaped, and colored plates, fruits, and vegetables were photographed. Approximately 4000 images per class make up the dataset’s total of over 41,509 images.
Preprocessing
Generally, the preprocessing process is going to enhance the image quality and remove the noises. These images do not contain any noises and pixel brightness enhancement is needed. Here, initialized to enhance the image pixel quality using a pixel brightness transformation based on the sigmoid stretching method. The sigmoid stretching in pixel brightness transformation is under pixel brightness and transformations are determined by the attributes of the pixel itself. In pixel brightness transformation, the value of the output pixel is relying only on the congruent value of the input pixel. The sigmoid function can be thought of as a continuous, non-linear activation function. Additionally, it is known as the logistic function.g (u, v)
The above equation (1) implies fs (u, v) – original image; g (u, v) – improved pixel value; t – threshold value, c – contrast factor. By altering the ‘n’ and ‘t’ it is possible to tailor and regulate the overall contrast enhancement and adjust the determined amount of lightness and darkness.
The pre-processed images are segmented using the Enhanced Watershed segmentation method. Typically, watershed transformation is used to segment data based on zones. A mathematical method for segmenting morphology that is based on topology theory is called the Improved Watershed Segmentation (IWS2) algorithm. Watersheds are referred to as the boundaries between regions that gather rainwater in the geography that supports the idea. In watershed segmentation, each pixel’s grayscale value is taken into account as the point’s height and the image is assumed to be a topological landform in geodesy. Each local minimum and its surrounding regions are referred to as a basin, and a basin’s edge is referred to as a watershed. The improved watershed segmentation algorithm’s precise process is as follows:
Morphological Restoration Filter: Pre-smoothing filters often perform a proper job of eliminating noise and irregular features, but they lose information about the contour boundaries, altering the contour of the region. Filtering and denoising the food photos can greatly protect the objective’s edge shape data. Additionally, it does not result in a change in the rebuilt image’s contour. The definition of morphological restoration is
Where: S
te
l
denotes structural element, n denotes the actual image, and S
x
denotes the outcome of the most recent iteration. Based on the initial and final acts, the morphological initial and final restoration action is defined as
Watershed Transformation Based on Marks: To force the marker to appear at any rate value, the gradient-recreated image H is separated using the drawn-out least change technique after the method is used to construct the Thd.
On the gradient image H
mk
, the watershed segmentation process is carried out using the minimum value forced minimum approach.
The segmented result is fed into Regression Neural Network (RNN) layer. The RNN is optimized using the modified dragonfly algorithm which helps to normalize the parameter of the network for achieving better accuracy. Here RNN is utilized to extract the features like shape, size, texture, and colour of the image. The proposed Optimized RNN with the BiLSTM method is shown in Fig. 2.

Optimized RNN with BiLSTM method.
When using an RNN, all the components of the input vector have roughly the same weight, unlike feedforward neural networks. The model may handle sequences of different lengths by simply reusing the weights. Another advantage is that fewer network-learning parameters (weights) are required. Additionally, using both the input vector and those images from the segmented phase, a number of the outputs for the subsequent stage was calculated using the data from the segmented phase. The formulas used to calculate the intermediate findings are abbreviated as units (blocks). Therefore, the relation given in Equations (9) and (10) can be utilized to define a block for the most fundamental type of recurrent network:
Where m t is a vector of input sequences and t is the iteration utilized to generate recurrent relations, The activation functions are represented by e1, e2. Z00, Z0m, Z pm , a0 and a p , are the weight matrices.
The RNN network is optimized using Modified dragonfly algorithm which help to normalize the parameter of the network for achieving better accuracy. In the Modified dragon-fly algorithm is used for optimization and it is used to resolve a problem by changing the interior parameter weights of the neural network to achieve the certain goals. The flow chart of the modified dragonfly optimization is depicted in Fig. 3.

Flowchart of Modified dragonfly optimization.
In this study, MDA is employed to enhance the system’s precision. The WOA is used in this MDA to update the optimal solution. Combining the dragon fly and whale optimization algorithms could speed up global convergence and improve the method’s viability. As a result, a combined approach is used to avoid the weaknesses brought on by the employment of individual optimization techniques. As a result, the WOA is used to update the optimal position. The next section provides a mathematical description of the modified dragonfly method and itslayers.
Layer 1: A random input is generated using equation (11) in this layer
Layer 2: Each dragonfly has a specific objective function based on equation (12).
Where f (i, l) represents the system’s objective. If the Objective Fn value is minimum, then the optimal solution is obtained. A fittest solution is updated based on the following five factors. Separation of dragonfly is shown in Fig. 4.

Separation of dragonfly.
Layer 3: The following equation is used to evaluate the separation Sep
i
between each i
th
individual dragonfly
According to the equation above, P is considered the neighbour of P j if there is less distance between P and P j than the distance at present. A neighboring individual has k neighbors.
Layer 4: Dragonfly alignment Alig
i
is evaluated by using the following equation for each i
th
individual dragonfly. Alignment of dragonfly is shown in Fig. 5.

Alignment of dragonfly.
Where, V j denotes the velocity consistency of the dragonfly
Layer 5: In each i
th
individual dragonfly, the cohesion Coh
i
is evaluated using the following equation
Cohesion of dragonfly is shown in Fig. 6.

Cohesion of dragonfly.
Layer 6: In order to evaluate the attraction towards food source FS
i
for i
th
individual dragonflies, the following equation is used:
Layer 7: In equation (18), the WOA is assisted in the updating process to increase DFA performance accuracy through the searching behavior.
Where,

Attraction to food.
The optimal feature set is fed into the BiLSTM layer. LSTM belongs to the class of recurrent neural networks in the field of AI. To classify the food item along with calories, we combine RNNs and BiLSTM in this work. An RNN-BiLSTM consists of five layers: the sequence input layer, 150 hidden-unit RNNs, 250 hidden-unit bidirectional LSTMs, FC layer, SoftMax layer, and classification output layer.
LSTM networks, a type of RNN structure with bidirectional long-term memory (BiLSTM), are effective and reliable at simulating sequences that have numerous dependencies, including time, and may be used for a variety of purposes. Afterward, a BiLSTM layer was applied. Segmented food images are arranged time-based, which means that the previous environment has a significant influence on the current condition.
Using the BiLSTM model, it is possible to solve this problem effectively. Many self-parameterized regulating gates within the BiLSTM module allow state information to be read, written and cleared. The cell’s complete informational capacity would be accessible if that door were to be opened. Recall that the forget gate was not activated, which resulted in the prior cell’s procedure failing. If nothing happens, the information from before could be “lost.” The output gate can independently decide whether to communicate the most recent cell output and the final state.
A dropout layer was added above the BiLSTM layer to mitigate the overfitting problem. By utilizing these dropout layers, we can prevent the issue of overfitting. Dropout helps achieve the goal of reducing overfitting, which is pursued in conjunction with the expansion of neural network layers. The BiLSTM layer is followed by the FC layer, the SoftMax layer, and finally the classification layer.
Calculating the volume of food
Every food item image is subjected to the square grid to determine its surface area. Each square grid has a comparable number of pixels, which stands for the quantity of food. Equation (13) represents the overall area of the food image.
Whereas, C is the calorie value, t is the table which has the calorie content of the food, m is the mass of the food item and mt is the table that has the mass of each food item. The diet food consumes only a minimum level of energy only.
MATLAB2019b is used to implement the proposed methodology. As a result, food images are trained in a novel Modified Deep Learning based Food Item Classification (MDEEPFIC) approach to classify the food items and include their calories. The output performance has been calculated, examined, and contrasted with the existing used classification methods. Existing and proposed techniques are compared based on their variations.
Calorie estimation
The volume (weight) of food and an estimate of the calorie values are used to determine the calorie values. The calories are widely used to calculate the total amount of energy in any food portion that contains the three primary dietary elements such as carbohydrates, proteins, and fats. The sample of calories table is shown in Table 1. A specific number of calories must be consumed by every day in an individual. If too much of calories are consumed in a day, it will lead to excess body weight.
Common calories table
Common calories table
Performance was tested with accuracy, precision, specificity, f measure, and recall using several assessment metrics for a comparison study. A statistical analysis of the parameters can be found below.

Experimental results of the proposed method.
Figure 8 depicts the results of the proposed MDEEPFIC with a sample of six different fruits and vegetable images. The input images (column-1) are pre-processed to eliminate the unwanted noise from the image which is shown in (column-2). The segmented food images are displayed in column-3. The segmented food images are classified and the calorie value is shown in column-4. In the experiment, the proposed method utilizes modified dragonfly optimization algorithm to provide a more accurate estimation of calorie value with varying sizes of fruits and vegetables.
Figure 9 illustrates that the proposed model has attained high accuracy in both training and testing. Improving the epoch value improves the model’s performance. In Fig. 10, the loss curve and epoch are displayed to demonstrate how the model loss decreases with increasing epoch size. As a result, the model’s predictions of outcomes were very accurate.

Training and testing accuracy of the proposed method.

Training and testing loss of the proposed method.
The effectiveness of existing methods was assessed to demonstrate that the proposed novel Food Item Classification with Calorie Calculation (MDEEPFIC) via the Deep Learning Network approach method works effectively with a high level of accuracy. Based on the F measure, recall, specificity, sensitivity, and accuracy, the proposed technique performs well. The accuracy rate demonstrates that the proposed approach is more effective than the prior techniques. The proposed method is compared to the existing LSV-SVM [25], F-RCNN [20], and DCNN [22] methods, respectively. Table 2. Illustrates the comparison of proposed techniques with the existing techniques.
Comparison of proposed technique with existing techniques
Comparison of proposed technique with existing techniques
Figure 11 illustrates the numerical analysis of the Proposed novel Food Item Classification with Calorie Calculation via Deep Learning Network (MDEEPFIC) approach and Existing methods LSV-SVM [25, 26], F-RCNN [20], DCNN [22] methods. This comparison demonstrates that the proposed MDEEPFIC performs better than the existing approaches. The accuracy of proposed MDEEPFIC has maximum accuracy of 99.36%, whereas existing models like LSV-SVM have 87.37%, F-RCNN has 91.4% and DCNN has 93.05%. It demonstrates that the proposed approach is an effective one and yields a highly accurate outcome. The precision of the proposed MDEEPFIC is 10.4%, 7.6%, and 4.8% increased by existing LSV-SVM, F-RCNN, and DCNN methods. The increased precision is due to the use of significant classification from a large database. The Recall of the proposed MDEEPFIC is 9.2%, 7.8%, and 4.78% better than the existing methods. The retrieval for positive results increases as recall increases. The proposed MDEEPFIC has a maximum F-measure value of 99.04%, which is relatively high compared to the existing methods. When compared to existing techniques, the proposed technique delivers better specificity of 98.07% respectively.

Performance of the proposed with the existing method.
In this research, a novel Modified Deep Learning-based Food Item Classification (MDEEPFIC) approach has been proposed to categorize the different food items from the dataset with their calorie values. Initially, the images are processed using the sigmoid stretching method to enhance the image quality and remove the noises. Consequently, the pre-processed images are segmented using Improved Watershed Segmentation (IWS2) algorithm. Recurrent Neural Network (RNN) is used to extract features like shape, size, textures, and color. The extracted features are then normalized using the modified dragonfly technique for same food calorie calculation. The Bi-LSTM is utilized to classify food products based on these pertinent aspects. Finally, using food area volume and calorie and nutrition measures based on mass value, the calorie value of the categorized food item is calculated. The experimental findings were then verified and the performance was evaluated utilizing evaluation metrics such as accuracy, precision, recall, specificity, and f-measure. To improve classification performance, the suggested novel Modified Deep Learning-based Food Item Classification (MDEEPFIC) approach technique acquired a 99.15% accuracy value. Results indicate that our suggested approach performed comparably well and has a lot of potential for promoting a healthy diet and effective findings. In the future, the computational speed, processing time, and automatic diet calculator can be improved by developing algorithms.
