As seen in Fig. 1, the methodology involves the classification of four distinct classes. The initial phase employs SVM as the primary classifier. Subsequently, the process unfolds with the integration of SVM and PCA for dimensionality reduction. Following this, HOG and LBP are applied for feature extraction. Finally, a combined approach utilizing HOG, LBP, and PCA is implemented.Fig. 1Schematic diagram illustrating the categorization process.DatasetDataset is obtained from Kaggle which is a combination of three different datasets. This dataset has 7023 images of brain MRI in total which are classified into training and testing folders as shown in Table 2. There are 4 classes namely glioma(Class G), meningioma(Class M), no tumor(Class N), and pituitary(Class P) in both the folders. As seen in Fig. 2, it includes MRI images taken from various planes. Table shows the class wise distribution of images in dataset.Table 2 Class-wise distribution of images in dataset.Fig. 2Sample MRI Images of Various Planes from the Dataset.Models and techniquesSVM is the main model used, and it is accompanied by techniques such as HOG, LBP for extracting the feature, and PCA for reducing the dimensionality.Support vector machine (SVM)The SVM algorithm is employed for categorization tasks, generating decision boundaries known as hyperplanes to segregate datasets. SVM is versatile in handling data containing both linear and nonlinear relationships. In instances where linear separation is feasible, the dataset is partitioned into two distinct groups by the hyperplane. However, when linear separation isn’t feasible, SVM employs a technique known as the kernel trick. Through this method, SVM transforms initial input space into a feature space of higher dimensionality where effective separation of data may be achieved7.Histogram of oriented gradients (HOG)Lee and Chung proposed HOG characteristics, inspired by the concept of object shape and state. This approach involves characterizing an object through the pixel intensity distribution and direction, referred as a gradient vector32. Systems designed for recognizing objects make use of HOG for image classification. In medical imaging, analyzing the frequency of different gradient orientations in a particular region helps identify patterns. The HOG feature extraction plugin simplifies the collection of these features, providing a straightforward and efficient method24.HOG feature is calculated as follows.Given an image divided into M×N cells, each cell containing m×n pixels, and orientation bins B in the histogram:1.For each cell.Compute the gradient magnitude (magx,magy) and orientation (θ) for each pixel.Calculate the histogram of gradient orientations (HOG histogram) for the cell by accumulating gradient magnitudes into orientation bins.2.For each block (comprising P×Q cells).Normalize the histograms of all cells within the block, typically using L2 normalization.Concatenate the normalized histograms from all cells within the block to form a block-level feature vector.Concatenate the block-level feature vectors from all blocks to obtain the final HOG feature vector representing the image.Local binay pattern(LBP)Ojala et al. introduced LBP. LBP has gained widespread use in feature extraction due to its simplicity in calculation and ease of extraction. This method finds extensive application in machine vision detection33.Given a central pixel Pc and its neighbouring pixels Pi for i = 0 to till N-1 were N is the sampling point numbers.$$LBP(P_{C})\sum_{i=0}^{N-1}\,s(P_i-P_c)X\;2^i$$
(1)
s(x) is referred for the sign function, which returns 1 if x is greater than or equal to 0 and 0 otherwise.Pi-Pc is the intensity difference between the neighboring pixel Pi and central pixel Pc .This formula represents the process of computing the LBP value for a single pixel in the image.Figure 3 displays the original image with lbp feature and hog feature extraction.Principal component analysis (PCA)PCA is an algorithm used for extracting the features and reducing the dimensions. This method involves a linear transformation of the features, reducing their dimensions from high to low34.Formula for PCA is given by.$$PC_x=\sum_{y=1}^n\,W_{xy}Z_y$$
(2)
Where PCx means x-th principal component, Wxy means the weight of the y-th feature in the x-th principal component, and Zy is the y-th original feature, n is the total number of original features.This formula represents a linear combination of the original features weighted by the corresponding weights Wxy to obtain the x-th principal component.Coding and experimentationIn our multiclass classification, remarkable outcomes are achieved with SVM utilizing HOG, LBP, and PCA. This section provides detailed insights into the coding and experimentation processes of this high-accuracy model.PreprocessingIn the preprocessing stage of the brain tumor classification methodology, each class undergoes a series of systematic processing steps to ensure consistency of input data and to improve input data’s quality. The key preprocessing steps are as follows.Reading and resizing imagesGrayscale medical images, representing different classes of brain tumors, are initially read from the dataset. Since the images may vary in resolution, they are resized to 64 × 64 pixels. This uniformity in image size helps streamline the feature extraction process and ensures that the classifier receives inputs of consistent dimensions.To ensure robustness in the preprocessing pipeline, error-handling mechanisms are implemented. These mechanisms detect and manage any issues encountered during image processing, such as corrupted files or unsupported formats, preventing disruptions in the workflow.Flattening imagesAfter resizing, the images are flattened into one-dimensional arrays. Flattening converts the 2D pixel matrix into a 1D vector, which simplifies the data structure for subsequent processing stages. This transformation is particularly useful when feeding data into machine learning models that require vectorized input.Data AugmentationIt is a critical preprocessing step aimed at increasing the size of the training dataset. In medical imaging, the available dataset is often limited, so augmentation techniques are used.Images are rotated, horizontally and vertically flipped or zoomed to increase the training dataset zize allowing the model to detect tumors of varying sizes.NormalizationTo further enhance the preprocessing, image’s pixels are normalized. This step scales the pixel values to a specific range (0 to 1), which helps to make the training process quicker.Histogram EqualizationThis is applied to improvize the contrast in cases where images suffer from poor contrast, making the tumor regions more distinguishable from surrounding healthy tissue. This step adjusts the intensity distribution of the image, improving the visibility of important features.After completing the preprocessing steps, the images are prepared for extraction of features.Feature extractionAs shown in Fig. 3, Grayscale medical image processing for brain tumor classification involves two key feature extraction methods. First, LBP captures texture patterns, forming a distinctive normalized histogram-based feature vector. Second, the HOG extracts shape information, by creating a flattened one-dimensional array. Figure 4 shows the original Image with LBP and HOG feature extraction.Local binary patterns (LBP)Is a widely used method, particularly effective for capturing texture patterns in grayscale images. LBP works by matching each of the pixels with its neighbors, generating a binary pattern based on intensity which is then altered into a decimal value, indicating the texture. The procedure is repeated across the entire image, and the frequency of each pattern is recorded in a histogram, resulting in a normalized feature vector.The robustness of LBP to illumination changes also adds to its effectiveness in medical imaging, where consistent lighting conditions are not always guaranteed.Histogram of oriented gradients (HOG)This method is primarily used to extract shape and structural information from images. HOG first devides the image into tiny cells and then it calculates the gradient direction and magnitude of those cells which is then altered into an exact number of orientation bins, creating a histogram that describes the local shape characteristics. Then it forms a feature vector which captures the distribution of edge directions within the image.In brain tumor classification, HOG is crucial because tumors often exhibit distinct shapes and structural features compared to surrounding healthy tissue. By focusing on the edges and contours within the image, HOG effectively captures these differences, contributing to the accurate identification and classification of tumors.Combined feature representationTo create a more robust and comprehensive feature representation for brain tumor classification, the LBP and HOG feature vectors are concatenated. This unified feature vector integrates both texture and shape information, offering a more complete descriptor of the image. While LBP emphasizes the fine-grained texture details, HOG provides complementary information about the overall shape and structure.The combination of LBP and HOG allows for the extraction of rich features that encapsulate both the micro-level texture patterns and macro-level shape characteristics of brain tumors.Fig. 3Flowchart describing the Feature Extraction Process.Fig. 4Original Image with LBP and HOG Feature Extraction.Data preparation and dimensionality reductionDuring data preparation, features and labels undergo transformations for model training. The dataset is devided into a set of training data and a set of testing data. Furthermore, standardizing feature vectors eliminates scale variations, prevents larger-magnitude features from dominating, and improves the overall stability of the model. Principal Component Analysis (PCA) reduces dimensionality, retaining 95% variance for a concise data representation. Transformed feature vectors from PCA serve as input for model training. A grid search fine-tunes the SVM, optimizing parameters for enhanced classification on the dataset. In summary, data handling and dimensionality reduction prepare for efficient brain tumor classification.Model trainingDuring the training phase, the dataset is meticulously prepared and features are extracted, resulting in standardized and dimensionality-reduced feature vectors. The dataset is then divided into a set of training data and a set of testing data, with the former teaching the SVM model to detect the patterns and their relationships within the data. This model’s parameters are optimized through grid search, exploring various combinations of regularization parameters and kernel types to maximize predictive accuracy. The fine-tuning process ensures the model generalizes well on unseen data, preventing overfitting.Evaluation and validationThe evaluation phase assesses the SVM model on a separate testing dataset with unseen brain tumor images. The testing data undergo preprocessing, and features are extracted using LBP and HOG techniques. Standardized, dimensionality-reduced test data is input into the SVM model with an optimized configuration. Post-testing, acc_val, prec_val, rec_val, and F1_val are computed. Validation sets, initially used for training and monitoring, now fine-tune models for optimal generalization.Pseudocode