diff --git a/article-image_segmentation_in_radiology/README.md b/article-image_segmentation_in_radiology/README.md new file mode 100644 index 0000000..9ab323c --- /dev/null +++ b/article-image_segmentation_in_radiology/README.md @@ -0,0 +1,40 @@ +# Image Segmentation in Medical Radiology: A State of the Art Review + +**Author:** Gusev Roman¹ +**Affiliation:** ¹Sigmoid, Machine Learning Engineer Intern, Chișinău, Republic of Moldova +**Email:** [gusev.roman.work@gmail.com](mailto:gusev.roman.work@gmail.com) +**Date:** 08.09.2025 + +## Article Summary + +With modern day technologies and advancements, Radiology became more sophisticated in technological aspect - MRIs, Rontgen and CTs evolved significantly and output images generated by them, has grown in number and resolution. Radiologists work, that deal with them on a daily basis, requires manual thorough analysis of each of them, becoming time-consuming and, overall, a routine work. Image Segmentation can help with identification of anomalies in human body in radiologic images by segmentation using ML/DL models, and reduce the time required to process images. Research paper reviews the state-of-the-art of Machine Learning and Radiology, focusing the attention on proposed solutions that involves advanced Deep Learning models, such as Convolutional Neural Networks and, less sophisticated Distance-based models, for example, K-Means Clustering, for the task of Image Segmentation. Provided code focuses on dataset preprocessing, since main research paper focus is on the state of the art. + +## Getting Started + +In order to work with this python file, Python 3.13.4 is recommended. To get started, do the following: + +1. **Prepare Your Environment**: Create Virtual Environment for Python or use existing: + + ```sh + python -m venv myenv + source myenv/bin/activate # On Windows: .\myenv\Scripts\activate + ``` + +2. **Install Requirements**: Install required packages from `requirements.txt` file using next command: + + ```sh + pip install -r requirements.txt + ``` + +3. **Execute Python File in the preferred IDE**: Execute `main.py` file in the preferred IDE to see the example in action. + ```sh + python -u "" + ``` + +## Source Code Explanation + +The code in this folder provides basic example of Image Dataset Preprocessing before training an DL Model. Key components are described below: + +- `src/main.py`: This file contains the example provided for the article (Dataset Preprocessing Step). It takes raw input radiologic images and applies preprocessing steps - RGB-LAB Conversion, CLA Histogram Equalization, Gaussian Filtering, Resize, trasnforming them into clean input data for the ML/DL algorithms. + +- `src/data/`: This folder contains the images used to demonstrate the input dataset in a Brain Tumor Segmentation Problem. `mask/` folder contains ground-truth binary mask. \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/article.md b/article-image_segmentation_in_radiology/article.md new file mode 100644 index 0000000..761a3b5 --- /dev/null +++ b/article-image_segmentation_in_radiology/article.md @@ -0,0 +1,1231 @@ +# Image Segmentation in Medical Radiology: A State of the Art Review + +**Author:** Gusev Roman¹ +**Affiliation:** ¹Sigmoid, Machine Learning Engineer Intern, Chișinău, Republic of Moldova +**Email:** [gusev.roman.work@gmail.com](mailto:gusev.roman.work@gmail.com) +**Date:** 08.09.2025 +**LaTeX PDF Version:** [Overleaf LaTeX](https://www.overleaf.com/read/nywyhnnbgknk#98cea9) _(NOTICE: due to changes in the politics regarding free subscription and compile time, compile PDF using Fast Compilation Method and then recompile using Normal Compilation Method)_ + +# Abstract + +With modern day technologies and advancements, Radiology became more +sophisticated in technological aspect - MRIs, Rontgen and CTs evolved +significantly and output images generated by them, has grown in number +and resolution. Radiologists work, that deal with them on a daily basis, +requires manual thorough analysis of each of them, becoming +time-consuming and, overall, a routine work. Image Segmentation can help +with identification of anomalies in human body in radiologic images by +segmentation using ML/DL models, and reduce the time required to process +images. This paper reviews the state-of-the-art of Machine Learning and +Radiology, focusing the attention on proposed solutions that involves +advanced Deep Learning models, such as Convolutional Neural Networks +and, less sophisticated Distance-based models, for example, K-Means +Clustering, for the task of Image Segmentation. + +***Keywords*:** Radiologic Imaging, Machine Learning, Deep Learning, +Convolutional Neural Network, U-Net, Image Segmentation, Computer-Aided +Detection + +# INTRODUCTION + +Radiology, since its discovery in 1895 by Wilhelm Conrad Röntgen, that +noticed how X-Rays can pass through various materials, had a long and, +at the same time, fast-paced technological advancement. First radiologic +imaging were performed in 1896, in order to investigate patients organs, +marking the birth of Radiology in Medicine [[1]](#ref_intro_2). This rapid enhancement +was a result of the harmful effects caused by Röntgen radiation in +medical scannings, such as: increasing cases of leukemia in patients +that underwent ionizing radiation procedures, severe dermatitis, eye +damage and so on, that caused people to delve deeper into the radiation +study and find way to make radiologic imaging safer both for patients +and doctors [[2]](#ref_intro_2). Throughout the evolution of radiologic imaging, it +became safer than it was back then, but, besides that, it also became +more advanced thanks to technological development, were found other +solutions for medical imaging, such as Computer Tomography (CT), +Magnetic Resonance Imaging (MRI), led to higher resolution radiologic +images, as well as higher number of images done during the procedure +[[3]](#ref_intro_3). This caused an increasing load on radiologists, making them prone +to errors in interpretation. For example, in a study at a tertiary care +center, $`\approx 18.4\%`$ of the total lungs radiologic images +performed had diagnostic errors [[4]](#ref_intro_4). A modern solution to assisting +radiologists in their field is implementing Machine Learning algorithms, +that involves computer-aided assistance in interpretation of radiologic +images, using Image Segmentation techniques, which can greatly reduce +routine work, shift current "algorithmic" approach to a personalized +patient care and increase the accuracy in conclusions [[5]](#ref_intro_5). This paper +reviews the state-of-the-art of Machine Learning and Radiology, focusing +the attention on proposed solutions that involves advanced Deep Learning +models, such as Convolutional Neural Networks and, less sophisticated +Distance-based models, for example, K-Means Clustering, for the task of +Image Segmentation. + +# RESEARCH METHODOLOGY + +The aim of this paper is to delve into how Machine Learning algorithms +can impact medical field, specifically Radiology, and analyze existing +studies about bridging Convolutional Neural Network models and +Radiologic Imaging. For this research paper, were retrieved studies +published from academic search engines, including "PubMed", +"Researchgate", "RSNA", "Arxiv", "Medium" and "ScienceDirect", that +included information about examples of implementations of Image +Segmentation in imaging, as well as the state of art of these fields, +separately and together. + +Besides analysis of existing research papers, were analyzed existing +implementations that has shown promising results in testing environment. +"GitHub" hosts several Jupyter Notebooks that show processes of +processing existing datasets, preparing them to feed to CNN models, as +well as training and testing those models on cleaned data. Thus, an +example of implementation was tried to produce in the frames of this +paper, as well as showing the results in the future sections. + +# LITERATURE REVIEW + +Machine Learning, as it was mentioned in the introduction, is a field of +Artificial Intelligence that involves using computational power in order +to produce output predictions by learning from input data using various +algorithms without being explicitly programmed. In other words, ML is +linked to the development of models, training them on datasets and +making predictions based on the learned patterns during the training +process. This subfield can be divided into two types: + +1. **Supervised Machine Learning**: involves machines using labeled + data (input data contains the actual true values for each training + sample), that, after training, predicts outcomes for unseen data + [[6]](#ref_intro_6). This field is subsequently divided into other two categories: + + 1. *Classification*: a problem becomes a classification task when + the output variable is a discrete, finite, or, in other words, + categorical one. An example of a classification problem can + serve the prediction of the presence of brain tumor. In this + case, the output of the model is either $`0`$ (absence) or $`1`$ + (presence), which becomes a binary classification problem. For + example, Logistic Regression, involves fitting the Sigmoid + Function to the input data, producing a binary output, Random + Forest Classifier, that ensembles multiple Decision Tree + Classifiers, are all examples of classification models. + + 2. *Regression*: a problem becomes a regression task when the + output variable is a continuous one, that is in an infinite + range of possible values, but not mandatory bounded by any + values. An example of a regression problem is the prediction of + the age based on physiological input data. In this case, age can + be taken from a range of values, that do not represent + categories. For example, Linear Regression, which is one of the + first models introduced in this field, involves fitting a line + to the input data, by adjusting weights and bias of the line + equation to the input data, Random Forest Regressor, that + ensembles, similar as in classification case, multiple Decision + Tree Regressors, are examples of regression models. + +2. **Unsupervised Machine Learning**: involves machines using unlabeled + data (input data does not contain actual true values for each + training sample), that discover various patterns and information in + the data without intervention (supervision) [[7]](#ref_intro_7). This can also be + divided in several types: + + 1. *Clustering*: a process of grouping unlabeled input data into + clusters based on their similarities, used to identify different + relationships between data points without prior knowledge about + data itself. For example, K-Means is a Clustering algorithm that + computes the centroids in the input data and assigns adjacent + points to the nearest centroid. + + 2. *Dimensionality Reduction*: a process of reducing the number of + features in the input data while retaining as much information + as possible. Principal Component Analysis is an example of a + Dimensionality Reduction algorithm, that captures the most + important features in the dataset using eigenvectors and + eigenvalues. + +As time passed, Deep Learning emerged as a subset of Machine Learning +with the development of Multilayered Artificial Neural Networks, that +simulates the decision-making ability of the human brain. Compared to +classical ML models, such as the ones mentioned above, ANNs are similar +to them, but consists of multiple levels of algorithms, called layers, +which makes them multilayered [[8]](#ref_intro_8). + +Artificial Neural Networks are formed of several components [[9]](#ref_intro_9): + +1. **Artificial Neuron**: a basic unit of a neural network, that + receives several inputs, either directly from input data or from + other neurons, processes them through a set of weights and an + activation function, and computes an output either to output or + other neurons (See fig. + 1) [[10]](#ref_intro_10). + +

+ Artificial Neuron Structure +

+

Fig. 1 - Artificial Neuron Structure

+ +2. **Activation Function**: a mathematical function applied to the + output of an Artificial Neuron, which introduces non-linearity into + the model and helps it learn complex patterns in the dataset. + +3. **Input Layer**: the first layer in an ANN, responsible for + receiving raw input data, corresponds to the features in the input + data and passes it to the next layers (Hidden Layers). + +4. **Hidden Layers**: layers between Input and Output Layers in an ANN, + responsible that perform most of the computations required by the + network, using activation functions in order to create + non-linearity. It can vary in number of layers, neurons per each + level and connections between neurons. + +5. **Output Layer**: the last layer in an ANN, that is responsible for + producing the output of the model. This layer contains $`n = K`$ + neurons, where + $`K \in \{class_1, class_2, ..., class_i\}, i = num_{classes}`$ is + the number of classes, in case of classification problem, or + $`K=1`$ - if it used for a regression task. +

+Artificial Neuron Structure +

Fig. 2 - Artificial Neural Network Structure - Layers

+ +Work with Radiologic Imaging involves visual analysis of the images, +detection of the deviations from normality and, at the end, +interpretation and conclusions. Computers do not have eyes that can +perceive images and perform visual analysis. Since images and videos can +serve as valuable information and necessity of processing and analysis +of above-mentioned media types, a subfield of AI - Computer Vision, has +evolved largely in the last decades. Computer Vision is concerned with +finding algorithms and ways that enable computers to interpret and +analyze visual information from digital images and videos, similar to +human sight [[11]](#ref_intro_11). Computer Vision is separated into several tasks +[[12]](#ref_intro_12): + +1. **Image Classification**: the task of predicting the label/class of + the given image, either binary or multiclass. An example of this is + predicting presence of liver metastases in the radiologic image (See + fig. 3). + +

+ LOH +

Fig. 3 - Image Classification Task

+ + +2. **Object Detection**: the task of identification and localization of + examples of a specific class on an image. Typically for this + problem, algorithms specifies the location and spatial extension of + the objects that are detected in the given image by plotting a + bounding box around the object. For example, in the same image of + liver metastases may be noticed boxes around several metastases in + the liver, as well as other classes in the image, such as: aorta, + stomach and other organs (See fig. + 4). + +

+ LOH +

Fig. 4 - Object Detection Task

+ + +3. **Semantic Segmentation**: the task of assigning to each pixel of + the given image a specific label/class, that results in binary masks + (for each possible target variable), where $`0`$ shows that + $`pixel_i \notin class_j`$, where $`class_j`$ is the class that is + being the target for the binary mask, and $`1`$ characterizes + $`pixel_i \in class_j`$, meaning that specific $`pixel_i`$ is + assigned $`class_j`$. In the previous image, after semantic + segmentation, every liver metastasis is colored red, without + specifics about instances (See fig. + 5). + +

+ LOH +

Fig. 5 - Semantic Segmentation Task

+ + +4. **Instance Segmentation**: the task similar to Semantic + Segmentation, but focused on delineation of the objects within the + same class instance-wise. In this case, each liver metastasis is + colored differently, marking each object of the class of metastases + (See fig. 6). + +

+ LOH +

Fig. 6 - Instance Segmentation Task

+ + +As a result, radiologists may benefit a lot from Computer Vision in +general [[13]](#ref_intro_13). The main focus of this paper is Image Segmentation, that has +the potency to specifically and accurately predict the position, shape +and size of the abnormalities in the images [[14]](#ref_intro_14). Depending on the +point of interest of the radiologists, they may be interested in general +interpretation, which can be done using Semantic Segmentation, or, in +case of particularities and separate instances of the analyzed class - +using Instance Segmentation. + +For the task of Image Analysis, the most appropriate type of ANNs is +Convolutional Neural Network. This type of ANN was first introduced in +the 1960s. Due to its promising performance results in Computer Vision, +it quickly became one of the most commonly used ANNs in this field +[[15]](#ref_intro_15) [[16]](#ref_intro_16). CNNs are formed of 4 layers: + +1. **Convolutional Layer**: a layer that uses a kernel filter that + slides across the input image step by step and, called convolution + operation, calculates the dot product between the weights of the + filter and pixel values of the image at each step and produces a new + matrix, called 2D activation map. This operation can be expressed as + it follows in Eq. [eq:activation] (See fig. + 7): + $$ + Activation\text{ }map = Input * Filter = \sum_{y=0}^{columns}\left( \sum_{x=0}^{rows} Input\left(x-p, y-q\right) Filter\left(x,y\right) \right) + $$ + +

+ LOH +

Fig. 7 - Convolution Operation

+ + +2. **Pooling Layer**: a layer that reduces the spatial dimensions + (down-sampling) of the feature maps while retaining the most + significant and valuable information, by the same mechanism of + sliding a filter across the input map. One of the most common types + of pooling layer is Max-Pooling layer, that selects highest value + pixel and retains it (See fig. + 8). + +

+ LOH +

Fig. 8 - Max-Pooling Layer

+ + +3. **Activation Function Layer**: each convolutional layer employs an + activation function that is applied to the output map, derived after + convolution, in order to add non-linearity for complex patterns and + ensure consistency in pixel values. One of the most popular + activation functions is ReLU (Rectified Linear Unit Function) as in + Eq. [eq:relu], however other functions, + such as: Sigmoid Function, can also be used. + $$ + f(x) = \begin{cases} + x, & \text{for } x > 0\\ + 0, & \text{for } x\leq 0 + \end{cases} + $$ + +4. **Fully-Connected Layer**: a layer that receives, after last pooling + or convolutional layer, the output of the maps, that is is + flattened, and that acts as input features. This layer is + responsible for the final prediction. + +Classical CNN architecture solves the problem of Image Classification, +but Image Segmentation takes a step further, by employing inside of CNN +an Encoder and Decoder, transforming it into a Fully Convolutional +Neural Network. The following structure is based on the original +research paper by Shelhamer et. al. (See fig. +9). + +

+LOH +

Fig. 9 - Fully Convolutional Neural Network Structure

+ + +1. **Encoder**: a part responsible for down-sampling, similar as in + description above, using sequences of Convolutional and Pooling + layers. Basically, this is the exactly above-mentioned CNN + structure, but without the fully-connected layer + +2. **Decoder**: a single layer that is responsible for up-sampling the + output from the Encoder in order to restore the original size of the + image and reconstruct spatial details that may have been lost during + the down-sampling process. This is done by transposed convolution + operations (See fig. + 10). + +

+ LOH +

Fig. 10 - Transposed Convolution Operation

+ + +One of the most used Image Segmentation models that was researched for +the task of Semantic Segmentation in Medical Imaging is U-Net, due to +its accuracy in segmentation of small targets, scalable architecture and +requirement of high computational efficiency algorithms, backed up by +the necessity of making fast decisions in critical situations, common in +medical and healthcare institutions [[18]](#ref_intro_18). + +U-Net is a Fully Convolutional Neural Network, but instead of using a +single up-sampling layer in Decoder, it implements multiple steps of +up-sampling. This increases the resolution of the output image. At the +same time, U-Net adds so-called skip connections, that are derived from +the concept of ResNet (Residual Networks) (See fig. +11). These connections are +shortcuts from earlier steps in Encoder to Decoder corresponding step. +This ensures that small details of the output feature maps at each step, +that may be lost during down-sampling, are kept across the algorithm. In +other words, these connections pass context to upper layers in Encoder +[[19]](#ref_intro_19). + +

+LOH +

Fig. 11 - U-Net Architecture

+ + +All these additions makes U-Net better at reconstruction of the original +image spatial characteristics, as well as overlapping binary maps onto +the image, creating the segments around predicted as positive class +pixels (See fig. 12). + +

+LOH +

Fig. 12 - Example of Image Segmentation using U-Net - Result on the +ISBI cell tracking challenge. (a) part of an input +image of the "PhC-US373" data set. (b) Segmentation +result (cyan mask) with manual ground truth (yellow border) +(c) input image of the "DIC-HeLa" data set. +(d) Segmentation result (random colored masks) with +manual ground truth (yellow border).

+ + +Medical Images contain many structures, both normal, such as organs, +bones, muscles, fat and others, and abnormal ones - tumors, lesions, +absence, duplication or changes in normal structures, etc. Segmentation, +in this context, covers the process of identification of both types of +structures in radiologic images. Since human body is not the same for +all people, some differences in particularities of their anatomical +characteristics, radiologic images can differ from one patient to +another, especially in abnormalities of the human body [[20]](#ref_intro_20). This +increases the complexity in training Image Segmentation models. + +U-Net, due to its approach at preserving context across the steps of the +algorithm, its authors, in their original paper, mentioned its +efficiency in medical image segmentation applications. Further will be +described a study case of U-Net Image Segmentation of tumors in brain +radiologic images. Some papers cover the problem of data acquisition, +since medical images comes in various formats, for example, "Digital +Imaging and Communications in Medicine" (*DICOM*) and "Neuroimaging +Informatics Technology Initiative" (*NIFTI*), that represent +3-dimensional data, that can be thought as stacked sliced 2-dimensional +images in all 3 plans - Axial, Coronal and Sagittal (See fig. +13) [[21]](#ref_intro_21). + +

+LOH +

Fig. 13 - The three perspective planes used in medical imaging - +Axial/Transversal, Coronal and Sagittal

+ + +Several datasets are available on web, including the one used in the +study case of Brain Tumor Segmentation using enhanced versions of U-Net +with EfficientNet-B4 Encoder, pretrained on ImageNet resources, which +means that the only part of the network that requires training, is +Decoder. This reduces training time and enables features extraction +using pretrained weights, resulting in higher accuracy in extracting +hierarchical features, such as edges, shapes, patterns and so on. The +proposed workflow of the model is displayed below (See fig. +14): + +

+LOH +

Fig. 14 - The three perspective planes used in medical imaging - +Axial/Transversal, Coronal and Sagittal

+ + +First step of the workflow focuses on the image preprocessing. ImageNet +brain tumor dataset, used in the referenced paper, is available on +ImageNet and contains 3064 T1-weighted contrast-enhanced images from 233 +patients with three kinds of brain tumor: meningioma, glioma and +pituitary tumor, alongside with true label of each sample, and tumor +border in format of a vector storing the coordinates of tumor border in +the format $`\left[x_1, y_1, x_2, y_2, ..., x_i, y_i\right]`$. All the +data is stored in `.mat` file. As addition to the dataset, original +authors provided a snippet to convert images to `.jpg` image format. +With additional implementation of extracting binary mask, that +represents ground truth segmentation, the code looks as it follows: + +``` matlab +input_folder = 'your input path'; +output_folder = 'your output path'; +file_list = dir(fullfile(input_folder, '*.mat')); +disp(file_list); +for i = 1:numel(file_list) + file_name = file_list(i).name; + file_path = fullfile(input_folder, file_name); + + mat_data = load(file_path); + cjdata = mat_data.cjdata; + + im1 = double(cjdata.image); + min1 = min(im1(:)); + max1 = max(im1(:)); + im = uint8(255/(max1-min1)*(im1-min1)); + + im1_mask = double(cjdata.tumorMask); + min1_mask = min(im1_mask(:)); + max1_mask = max(im1_mask(:)); + im_mask = uint8(255/(max1_mask-min1_mask)*(im1_mask-min1_mask)); + + label = cjdata.label; + + tumorBorder = cjdata.tumorBorder; + + disp(tumorBorder); + + label_folder = fullfile(output_folder, num2str(label)); + if ~exist(label_folder, 'dir') + mkdir(label_folder); + end + + [~, file_name_base, ~] = fileparts(file_name); + output_file_path = fullfile(label_folder, strcat(file_name_base, '.jpg')); + output_file_path_mask = fullfile(label_folder, strcat(file_name_base, '_mask', '.jpg')); + + imwrite(im, output_file_path); + imwrite(im_mask, output_file_path_mask); +end +``` + +As a result, an example of input images is provided below (See fig. +15). On the left side, can be +seen the original image of the brain and on the right side the +corresponding binary mask that represents the surrounded brain tumor +border with white color. +

+ +| ![TumorPresent](src/figures/1.jpg) | ![TumorPresentMask](src/figures/1_mask.jpg) | +| :--------------------------------------: | :-----------------------------------------: | +|

(a) Example of an MRI Image with brain tumor present

|

(b) Corresponding Binary Mask with segmented brain tumor

| +

Fig. 15 - First Sample of the Brain Tumor Dataset

+However, images are converted to *RGB* color map, which, taken in +consideration the importance of image preprocessing, can be an obstacle +in this process. One of the outlined preprocessing steps is CLAHE +(Contrast Limited Adaptive Histogram Equalization), which is is used to +improve the contrast of images, but, instead of changing the contrast of +the entire image, it divides images in smaller parts and adjusts their +contrast separately, avoiding getting the image too bright or too dark +[[22]](#ref_intro_22). An example of advantage of this approach can be seen in the +following example (See fig. +16): + +

+LOH +

Fig. 16 - Comparison between original, HE, and CLAHE equalized X-ray +images with corresponding histograms

+ + +As it may be seen, CLAHE provides a better histogram equalization than +in traditional HE method. As it was mentioned, converted images are in +*RGB* color space, but CLAHE, applied on this color map, impacts the +coloring of the images, since it modifies at least one of the three +color channels, that are highly-correlated, thus producing new artifact +colors [[23]](#ref_intro_23), which can make ML Models capture new unwanted data as +patterns. Besides that, in imaging, an important aspect is +device-dependency. *RGB* is device-dependent, meaning images in *RGB* +are interpreted differently depending on the device it is viewed. Thus, +a need of a consistent and device-independent color map has appeared. +This need was full-filled in 1976 when *CIELAB* color map was developed. +*CIELAB* is a color map that is formed of 3 components: $`L`$ - +Perceptual Lightness ($`L \in [0, 100]`$, where $`0 = Black`$ and +$`100 = White`$), $`a^*`$ - first color component +($`a^* \in [-127, 127]`$, where $`-127 = Green`$ and $`127 = Red`$) and +$`b^*`$ - second color component ($`a^* \in [-127, 127]`$, where +$`-127 = Yellow`$ and $`100 = 127`$), which can represent the gamut of +human color perception, thus making it the most appropriate for accurate +color interpretation in images, especially in restoring details CNN +output [[24]](#ref_intro_24). For example, *RGB* can represent a small portion of the +range of possible color nuances (See fig. +17). + +

+LOH +

Fig. 17 - Comparison between RGB and CIELAB color +spaces

+ + +As it may be seen, the triangle on the left side represents how *RGB* +captures color nuances, being a subset of the possible colors +represented in *CIELAB* color space. Since *CIELAB* contains a separate +channel for Lightness, it can be used for CLAHE algorithm, thus leaving +color channels untouched, that will not produce color artifacts, making +it appropriate for application in Medical Imaging. + +Returning back to the discussed research paper on U-Net application in +Radiology Imaging, one important step in dataset preprocessing is +conversion from *RGB* color space to *CIELAB*. + +``` python +# Using OpenCV, read radiologic images. +img_rgb = cv2.imread(os.path.join(dataset_directory, filename)) +# By default, OpenCV library reads images in BGR color space, therefore, for the conversion to LAB, images should be in RGB color space. +img_rgb = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2RGB) +# OpenCV supports LAB color space and offers functions to operate with LAB format. +img_lab = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2LAB) +``` + +After conversion to *CIELAB* color space, CLAHE algorithm is safely +applied on the $`L`$ channel. Thus, the contrast of the images are +enhanced. + +``` python +# Initialize CLAHE object using default arguments +clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8)) +# Split the image by channels (L, a*, b*) +l, a, b = cv2.split(img_lab) +# Apply CLAHE Transformation on L channel +l_clahe = clahe.apply(l) +# Restore back the image by combining all 3 channels +img_lab_clahe = cv2.merge([l_clahe, a, b]) +# Convert back to RGB for visualization (alternativelly, save in .tiff format, because supports float pixel values) +img_lab_rgb = cv2.cvtColor(img_lab, cv2.COLOR_LAB2RGB) +img_lab_clahe_rgb = cv2.cvtColor(img_lab_clahe, cv2.COLOR_LAB2RGB) +``` + +Next step of preprocessing in the paper is applying Gaussian Filter in +order to reduce the noise and smooth the image, increasing the overall +quality of the image. + +``` python +# Apply Gaussian Filter with kernel size 5x5 and standard deviation on X-axis 0 +img_lab_clahe_gauss = cv2.GaussianBlur(img_lab_clahe, (5, 5), 0) +# Convert LAB image to RGB for visualization +img_lab_clahe_gauss_rgb = cv2.cvtColor(img_lab_clahe_gauss, cv2.COLOR_LAB2RGB) +``` + +After that, all the resulting images are resized to $`256\times256`$ to +imply consistency in images and adhere to U-Net architecture input +dimensions, and normalized. All of the masks were also resized to the +same dimension, normalized and reshaped to include a single channel. + +As an example of the preprocessing, below is provided, step-by-step, +modifications of the images alongside with ground-truth segmentation +from the training examples (See fig. +18). + +

+LOH +

Fig. 18 - Original and Applied LAB conversion and CLAHE +algorithm - Original dimension

+ + +The proposed model in the reviewed paper is Multi-Scale Attention U-Net +with EfficientNet-B4 Encoder. As it was mentioned, U-Net is formed of +two components - Encoder and Decoder. + +1. **Encoder**: EfficientNet-B4 encoder that is pretrained of ImageNet + dataset, provides very high performance results, responsible for + hierarchical feature extraction and captures low-level and + high-level features useful for brain tumor segmentation. Besides + classical convolution layer, it uses the concept of Mobile Inverted + Bottleneck Convolution (MBConv) layers (See fig. + 19). + +

+ LOH +

Fig. 19 - EfficientNet-B4 Architecture

+ + + First step is to pass input image through simple convolution layer, + while the rest of the blocks are MBConv layers, that comprises + multiple convolution operations. Initially, $`1\times1`$ convolution + block expands the number of input channels, then depth-wise + $`3\times3`$ convolution block is applied over produced channels. + After that, the output is sent through a skip connection to the end + of the layer and, at the same time, to the Squeeze-and-Excitation + block, that reduces the map, applies non-linear activation function + and restores the spatial dimensions, where first the map is squeezed + and then expanded back to original shape. This allows model to + perceive important feature better, since their "weights" are higher + than for non-important features, and this type of layer can perceive + them better (See fig. + 20). + +

+ LOH +

Fig. 20 - MBConv Architecture

+ + +2. **Decoder**: Multi-Scale Attention architecture is embedded inside + of the Decoder and focuses on spatial position of important features + in the encoder feature maps by applying additional residual + attention blocks and combining them with features from the encoder + using skip connections, improving model segmentation on relevant + features. Each decoder block acts as a Residual Attention Block, + which combines skip connections with multi-scale attention + techniques. First, as in original U-Net, feature map is up-sampled + using transposed convolution, increasing spatial dimensions of the + maps. "Multi-Scale", in this context, uses convolutions with + different kernel sizes, in order to obtain contextual information at + different scales. After that, using simple convolution, all the + generated maps are merged into a single one. An attention mask is + produces by passing multiscale features through another convolution + and activation layer, that is later applied through element-wise + multiplication to the feature map (See fig. + 21). + +

+ LOH +

Fig. 21 - Multi-Scale Attention Decoder

+ + +In the paper, researchers focused on several metrics: + +1. **Dice similarity coefficient (DSC)**: measures the overlap between + Predicted Segmentation and Ground Truth Segmentation. Higher values + of DSC coefficient indicate accurate tumor localization. + + +
+ +2. **Intersection over union (IoU)**: known as Jaccard Index, measures + the ratio between the intersection and union between Predicted + Segmentation and Ground Truth Segmentation. Compared to DSC, IoU + penalizes more under- and over-segmentation. However, those two + metrics are pretty similar and offer relatively similar values. One + of the most used metrics is DSC, due to the fact that, using DSC, + can be computed Dice Loss $`Dice_{Loss} = 1 - DSC`$, that is + differentiable, while IoU is not. + + +
+ +3. **Mean intersection over union (mean IoU)**: measures the average + intersection between the predicted and ground-truth segmentation + across all classes in order to give a general interpretation of + models performance. + + +
+ +4. **Precision**: measures the ratio of correctly identified tumor + pixels of the total number of pixels that were classified as tumors. + + +
+ +5. **Recall**: measures the ratio of correctly classified tumor pixels + and the total number of actual tumor pixels. + + +
+ +6. **Specificity**: measures the ratio between correctly identified + non-tumor pixels and the total number of actual non-tumor pixels. + + +
+ +7. **Accuracy**: measures the ratio of correctly predicted pixels to + the total number of pixels. This metric, taken alone, may be + misleading, because it does not take into consideration cases of + imbalanced datasets (ratio of one class to another class is very + high, e.g. Brain Tumor Classification Problems). For example, if a + model was trained on an imbalanced dataset, it might learn to + predict the majority class to all samples, and since there is a very + high number of samples of majority class, this metric will show high + accuracy, but the model is still performing badly, since it + misclassifies all of the minority class. + + +
+ +As a result, their proposed enhanced U-Net performed very well. +Specifically, they performed a comparative analysis between different +types of EfficientNet-B family of Encoders. With EfficientNet-B4 +Encoder, their model obtained highest DSC, IoU and Recall, that resulted +in the best segmentation of tumor pixels. Besides that, since medicine +is a field where mistakes may have heavy consequences, it is a practice +to sacrifice Precision in order to obtain higher Recall, which means +that it is better to misclassify some radiologic images that exhibit +non-tumor patients rather than to misclassify some patients that +actually have a tumor or multiple ones as being non-tumor patients. +Besides that, EfficientNet-B4 Encoder manifested lower consumption of +computational power compared to EfficientNet-B6, that had similar +results in performance metrics. + +
+ +| **Model** | **DSC** | **IoU** | **Precision** | **Recall** | **Specificity** | +|:------------------|:--------|:--------|:--------------|:-----------|:----------------| +| *EfficientNet-B0* | 0.9127 | 0.8476 | 0.9756 | 0.8683 | 0.9998 | +| *EfficientNet-B1* | 0.9026 | 0.8419 | 0.9738 | 0.8645 | 0.9997 | +| *EfficientNet-B2* | 0.9289 | 0.8725 | 0.9705 | 0.8983 | 0.9997 | +| *EfficientNet-B3* | 0.8986 | 0.8222 | 0.9864 | 0.8327 | 0.9999 | +| *EfficientNet-B4* | 0.9339 | 0.8795 | 0.9657 | 0.9103 | 0.9996 | +| *EfficientNet-B5* | 0.8806 | 0.8212 | 0.9647 | 0.8498 | 0.9996 | +| *EfficientNet-B6* | 0.9327 | 0.8778 | 0.9671 | 0.9063 | 0.9997 | +| *EfficientNet-B7* | 0.9171 | 0.8120 | 0.9817 | 0.8664 | 0.9998 | + +Comparison of EfficientNet-B Encoder Family variants performance + +
+ +As a result of testing the model with those encoder, they obtained the +following plot (See fig. +22). It may be noticed that +EfficientNet-B4 obtained the closest segmentation to the original +ground-truth one. + +

+LOH +

Fig. 22 - Predicted Binary Masks by Multi-Scale Attention U-Net with +each Encoder of EfficientNet-B Family alongside with Ground-Truth Mask +and original Image.

+ + +Another study focused on implementation of Optimized Fuzzy K-Means +clustering algorithm for Brain Tumor Segmentation. K-Means clustering is +an iterative, centroid-based clustering Unsupervised Machine Learning +algorithm that segments a dataset into similar groups based on the +distance between their centroids [[25]](#ref_intro_25). In classical K-Means +Clustering, the steps to train the model are the following: + +1. Initialization of the number of Clusters $`K`$. This should be done + before-hand. + +2. Random selection of $`K`$ points from the dataset and are assigned + different labels. + +3. Each point in the dataset is assigned to the closest cluster $`K_i`$ + by Euclidian Distance. + + +
+ +4. After all the points are assigned, recalculate the centroids as mean + of all point assigned to the cluster $`K_i`$. + + +
+ +5. Repeat iteratively previous two steps until no change in clusters + centroids or maximum iterations achieved (See fig. 23). + +

+LOH +

Fig. 23 - Example of K-Means Algorithm

+ + +Fuzzy K-Means works using Fuzzy Logic. It computes a Membership Matrix +for each data point in contrast to Euclidean Distance applied in the +original K-Means. This approach allows overlapping clusters and adds +flexibility, since it offers soft-decision results in format of +probabilities of data points cluster membership. + +In the above-mentioned study, authors used Fuzzy K-Means Clustering for +Brain Tumor Segmentation. As a preprocessing step of the radiologic +images, they implemented Gaussian Blur and Normalization, similar to the +approach from previous study case. However, no additional Contrast +Enhancement techniques were applied. + +As for the model, they similarly used additional implementations, such +as: + +1. **Centroid Initialization with K-Means++**: one centroid is selected + at random and subsequent selection is done based on the probability + that is proportional to the square of the Euclidean Distance between + the data point and closest selected center. + +2. **Use of Vectorization**: in membership update step, they used + vectorized operations of matrices, and others. + +As evaluation metrics, they used DSC, IoU, Precision, Recall, Accuracy +and F1-Score. + +As a result, they obtained the following predictions (See fig. +24). As it may be seen, Fuzzy +K-Means performed close to the ground-truth binary masks segmentation. +Its predictions overall visual similarities with true label masks can be +seen, however False Positives and False Negatives can still be seen, +but, since the approach is much less complex than CNNs, results are +impressive. + +

+LOH +

Fig. 24 - Segmentation Results (a) Original Image +(b) Preprocessed Image, (c) +Ground-Truth Binary Mask (d) K-Means Clustering, +(e) FCM (f) Proposed Fuzzy K-Means +Clustering

+ + +At the end of the paper, they offered the performance metrics of the +Fuzzy K-Means Clustering in Brain Tumor Image Segmentation. The +performance is very high, higher than in the previous study case with +U-Net as a model. This also may be due to the differences in the dataset +sizes, as well as other factors that may affect the metric performances. +Besides this, not much information was provided on the algorithms and +implementations in both articles, therefore no comparison between them +may be done. + +
+ +| **Image No.** | **DSC** | **IoU** | **Precision** | **Recall** | **Accuracy** | **F1 Score** | +|:---|:---|:---|:---|:---|:---|:---| +| *1* | 0.9776 | 0.9562 | 0.9899 | 0.9656 | 0.9960 | 0.9776 | +| *2* | 0.9724 | 0.9464 | 0.9781 | 0.9669 | 0.9972 | 0.9724 | +| *3* | 0.9721 | 0.9457 | 0.9699 | 0.9743 | 0.9994 | 0.9721 | +| *4* | 0.9707 | 0.9430 | 0.9617 | 0.9797 | 0.9988 | 0.9707 | +| *5* | 0.9145 | 0.8825 | 0.9928 | 0.8477 | 0.9862 | 0.9145 | +| *6* | 0.9861 | 0.9778 | 0.9852 | 0.9101 | 0.9912 | 0.9461 | +| *Average* | 0.9072 | 0.9419 | 0.9796 | 0.9407 | 0.9948 | 0.9589 | + +Analysis of Fuzzy K-Means Clustering Performance Metrics in Brain Tumor +Segmentation Task + +
+ +# CONCLUSIONS + +High performance in Image Segmentation, for example Brain Tumor +Segmentation, manifested by various Machine Learning Models, especially +U-Net and Fuzzy K-Means Clustering, specifically tailored for +Applications in Medical Imaging, is a result of complex work of many +people. As demonstrated, those models may represent a valuable +assistance for radiologists in their routine work by reducing the amount +of time spent per each image and assisting in image exploration and, +possibly, reduce the rate of error in their practice. + +# Bibliography +
+ +
+ +\[1\] +M. Tubiana, “Wilhelm conrad +röntgen and the discovery of x-rays,” *Bull Acad Natl Med*, vol. 180, +no. 1, pp. 97–108, Jan. 1996. + +
+ +
+ +\[2\] +M. F. Vardeu, O. Larentis, I. +Vecchio, I. Gorini, M. Martini, N. Bragazzi, A. D’Ambra, M. Ruggieri, +and C. Tornali, “History of use and abuse of x-ray: The early 20th +century italian pediatrics school,” *Acta Biomed*, vol. 91, no. 1, pp. +113–117, Mar. 2020. + +
+ +
+ +\[3\] +M. Winder, A. J. Owczarek, J. +Chudek, J. Pilch-Kowalczyk, and J. Baron, “[Are we overdoing it? Changes +in diagnostic imaging workload during the years 2010–2020 including the +impact of the SARS-CoV-2 +pandemic](https://doi.org/10.3390/healthcare9111557),” *Healthcare*, +vol. 9, no. 11, 2021. + +
+ +
+ +\[4\] +Ö. Kasalak, H. Alnahwi, R. +Toxopeus, J. P. Pennings, D. Yakar, and T. C. Kwee, “Work overload and +diagnostic errors in radiology,” *Eur J Radiol*, vol. 167, p. 111032, +Aug. 2023. + +
+ +
+ +\[5\] +R. Najjar, “Redefining radiology: +A review of artificial intelligence integration in medical imaging,” +*Diagnostics (Basel)*, vol. 13, no. 17, Aug. 2023. + +
+ +
+ +\[6\] +A. Alnuaimi and T. Albaldawi, “[An +overview of machine learning classification +techniques](https://doi.org/10.1051/bioconf/20249700133),” *BIO Web of +Conferences*, vol. 97, p. 00133, Apr. 2024. + +
+ +
+ +\[7\] +S. Naeem, A. Ali, S. Anam, and M. +Ahmed, “[An unsupervised machine learning algorithms: Comprehensive +review](https://doi.org/10.12785/ijcds/130172),” *IJCDS Journal*, vol. +13, pp. 911–921, Apr. 2023. + +
+ +
+ +\[8\] +Z. Hao, “[Deep learning review and +discussion of its future +development](https://doi.org/10.1051/matecconf/201927702035),” *MATEC +Web of Conferences*, vol. 277, p. 02035, Jan. 2019. + +
+ +
+ +\[9\] +V. Gupta, “[Understanding +feedforward neural +networks](https://learnopencv.com/understanding-feedforward-neural-networks/),” +*LearnOpenCV*. Feb-2024. + +
+ +
+ +\[10\] +AFIT Data Science Lab, “Artificial +neural network fundamentals · AFIT data science lab r programming +guide.” , 2025. + +
+ +
+ +\[11\] +S. Shelke, I. Pathak, A. Sangai, +D. Lunge, K. Shahale, and H. Vyawahare, “[A review paper on computer +vision](https://doi.org/10.48175/IJARSCT-8901),” *International Journal +of Advanced Research in Science, Communication and Technology*, pp. +673–677, Mar. 2023. + +
+ +
+ +\[12\] +P. M. Cheng, E. Montagnon, R. +Yamashita, I. Pan, A. Cadrin-Chênevert, F. Perdigón Romero, G. +Chartrand, S. Kadoury, and A. Tang, “[Deep learning: An update for +radiologists](https://doi.org/10.1148/rg.2021200210),” *RadioGraphics*, +vol. 41, no. 5, pp. 1427–1445, 2021. + +
+ +
+ +\[13\] +Z. Mustafa and H. Nsour, “[Using +computer vision techniques to automatically detect abnormalities in +chest x-rays](https://doi.org/10.3390/diagnostics13182979),” +*Diagnostics*, vol. 13, no. 18, 2023. + +
+ +
+ +\[14\] +I. Purwono, A. Ma’arif, W. +Rahmaniar, H. Imam, H. I. K. Fathurrahman, A. Frisky, and Q. M. U. Haq, +“[Understanding of convolutional neural network (CNN): A +review](https://doi.org/10.31763/ijrcs.v2i4.888),” *International +Journal of Robotics and Control Systems*, vol. 2, pp. 739–748, Jan. +2023. + +
+ +
+ +\[15\] +M. M and S. P, “[COVID-19 +infection prediction from CT scan images of lungs using iterative +convolution neural network +model](https://doi.org/10.1016/j.advengsoft.2022.103214),” *Advances in +Engineering Software*, vol. 173, p. 103214, 2022. + +
+ +
+ +\[16\] +J. Long, E. Shelhamer, and T. +Darrell, “[Fully convolutional networks for semantic +segmentation](http://arxiv.org/abs/1411.4038),” *CoRR*, vol. +abs/1411.4038, 2014. + +
+ +
+ +\[17\] +M. A. Al Mamun and I. Kadir, +“[An-eye: SAFE NAVIGATION IN FOOTPATH FOR VISUALLY IMPAIRED USING +COMPUTER VISION +TECHNIQUES](https://doi.org/10.13140/RG.2.2.19394.66242),” PhD thesis, +2020. + +
+ +
+ +\[18\] +X.-X. Yin, L. Sun, Y. Fu, R. Lu, +and Y. Zhang, “U-Net-Based medical image segmentation,” *J Healthc Eng*, +vol. 2022, p. 4189781, Apr. 2022. + +
+ +
+ +\[19\] +O. Ronneberger, P. Fischer, and T. +Brox, “[U-net: Convolutional networks for biomedical image +segmentation](http://arxiv.org/abs/1505.04597),” *CoRR*, vol. +abs/1505.04597, 2015. + +
+ +
+ +\[20\] +K. Boutis, S. Cano, M. Pecaric, T. +Welch-Horan, B. Lampl, C. Ruzal-Shapiro, and M. Pusic, “[Interpretation +difficulty of normal versus abnormal radiographs using a pediatric +example](https://doi.org/10.36834/cmej.36654),” *Canadian medical +education journal*, vol. 7, pp. e68–77, Mar. 2016. + +
+ +
+ +\[21\] +J. Walsh, A. Othmani, M. Jain, and +S. Dev, “[Using u-net network for efficient brain tumor segmentation in +MRI images](https://doi.org/10.1016/j.health.2022.100098),” *Healthcare +Analytics*, vol. 2, p. 100098, 2022. + +
+ +
+ +\[22\] +GeeksforGeeks, “CLAHE histogram +equalization OpenCV.” +, +May-2020. + +
+ +
+ +\[23\] +W. Yussof, “Performing contrast +limited adaptive histogram equalization technique on combined color +models for underwater image enhancement,” Jan. 2013. + +
+ +
+ +\[24\] +D. Chen and H. Zhao, “[CCD-net: +Color-correction network based on dual-branch fusion of different color +spaces for image dehazing](https://doi.org/10.3390/app15063191),” +*Applied Sciences*, vol. 15, p. 3191, Mar. 2025. + +
+ +
+ +\[25\] +E. Kavlakoglu and V. Winland, +“What is k-means clustering?” +, +26-Jun-2024. + +
+ +
diff --git a/article-image_segmentation_in_radiology/requirements.txt b/article-image_segmentation_in_radiology/requirements.txt new file mode 100644 index 0000000..b52edd0 Binary files /dev/null and b/article-image_segmentation_in_radiology/requirements.txt differ diff --git a/article-image_segmentation_in_radiology/src/data/1.png b/article-image_segmentation_in_radiology/src/data/1.png new file mode 100644 index 0000000..38bb288 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/data/1.png differ diff --git a/article-image_segmentation_in_radiology/src/data/masks/1.png b/article-image_segmentation_in_radiology/src/data/masks/1.png new file mode 100644 index 0000000..adf5acf Binary files /dev/null and b/article-image_segmentation_in_radiology/src/data/masks/1.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/0YsZpqg6n3.svg b/article-image_segmentation_in_radiology/src/figures/0YsZpqg6n3.svg new file mode 100644 index 0000000..e0b2ad4 --- /dev/null +++ b/article-image_segmentation_in_radiology/src/figures/0YsZpqg6n3.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/src/figures/1.jpg b/article-image_segmentation_in_radiology/src/figures/1.jpg new file mode 100644 index 0000000..a5da5c5 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/1.jpg differ diff --git a/article-image_segmentation_in_radiology/src/figures/18iYaeeFPP.svg b/article-image_segmentation_in_radiology/src/figures/18iYaeeFPP.svg new file mode 100644 index 0000000..167ef00 --- /dev/null +++ b/article-image_segmentation_in_radiology/src/figures/18iYaeeFPP.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/src/figures/1_mask.jpg b/article-image_segmentation_in_radiology/src/figures/1_mask.jpg new file mode 100644 index 0000000..d4d1cc3 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/1_mask.jpg differ diff --git a/article-image_segmentation_in_radiology/src/figures/8N1fdjIn4p.svg b/article-image_segmentation_in_radiology/src/figures/8N1fdjIn4p.svg new file mode 100644 index 0000000..6e6b05e --- /dev/null +++ b/article-image_segmentation_in_radiology/src/figures/8N1fdjIn4p.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/src/figures/Figure_1.png b/article-image_segmentation_in_radiology/src/figures/Figure_1.png new file mode 100644 index 0000000..f7efc14 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/Figure_1.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/MUo75RLTeA.svg b/article-image_segmentation_in_radiology/src/figures/MUo75RLTeA.svg new file mode 100644 index 0000000..1bb3845 --- /dev/null +++ b/article-image_segmentation_in_radiology/src/figures/MUo75RLTeA.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/src/figures/MtW340FoOW.svg b/article-image_segmentation_in_radiology/src/figures/MtW340FoOW.svg new file mode 100644 index 0000000..135f32e --- /dev/null +++ b/article-image_segmentation_in_radiology/src/figures/MtW340FoOW.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/src/figures/O3hbUhAKh6.svg b/article-image_segmentation_in_radiology/src/figures/O3hbUhAKh6.svg new file mode 100644 index 0000000..cf0de89 --- /dev/null +++ b/article-image_segmentation_in_radiology/src/figures/O3hbUhAKh6.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/src/figures/b4net.png b/article-image_segmentation_in_radiology/src/figures/b4net.png new file mode 100644 index 0000000..ed21ef3 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/b4net.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/brain_plans.jpg b/article-image_segmentation_in_radiology/src/figures/brain_plans.jpg new file mode 100644 index 0000000..5be30e5 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/brain_plans.jpg differ diff --git a/article-image_segmentation_in_radiology/src/figures/clahe.png b/article-image_segmentation_in_radiology/src/figures/clahe.png new file mode 100644 index 0000000..3299489 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/clahe.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/conv2d.png b/article-image_segmentation_in_radiology/src/figures/conv2d.png new file mode 100644 index 0000000..5405e0e Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/conv2d.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/cv_1.png b/article-image_segmentation_in_radiology/src/figures/cv_1.png new file mode 100644 index 0000000..3bfd1bc Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/cv_1.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/cv_2.png b/article-image_segmentation_in_radiology/src/figures/cv_2.png new file mode 100644 index 0000000..4f0e27b Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/cv_2.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/cv_3.png b/article-image_segmentation_in_radiology/src/figures/cv_3.png new file mode 100644 index 0000000..31c4368 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/cv_3.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/cv_4.png b/article-image_segmentation_in_radiology/src/figures/cv_4.png new file mode 100644 index 0000000..04a7cf9 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/cv_4.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/fcn.png b/article-image_segmentation_in_radiology/src/figures/fcn.png new file mode 100644 index 0000000..6d65ece Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/fcn.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/kmeans.png b/article-image_segmentation_in_radiology/src/figures/kmeans.png new file mode 100644 index 0000000..5c43e32 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/kmeans.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/layers.png b/article-image_segmentation_in_radiology/src/figures/layers.png new file mode 100644 index 0000000..2d016d6 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/layers.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/max_pool.png b/article-image_segmentation_in_radiology/src/figures/max_pool.png new file mode 100644 index 0000000..8291f57 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/max_pool.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/mbconv.png b/article-image_segmentation_in_radiology/src/figures/mbconv.png new file mode 100644 index 0000000..2b63568 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/mbconv.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/metrics.png b/article-image_segmentation_in_radiology/src/figures/metrics.png new file mode 100644 index 0000000..e1d7a1f Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/metrics.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/msad.png b/article-image_segmentation_in_radiology/src/figures/msad.png new file mode 100644 index 0000000..e96f1b4 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/msad.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/neuron.jpg b/article-image_segmentation_in_radiology/src/figures/neuron.jpg new file mode 100644 index 0000000..33bdb50 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/neuron.jpg differ diff --git a/article-image_segmentation_in_radiology/src/figures/oHnJx7m981.svg b/article-image_segmentation_in_radiology/src/figures/oHnJx7m981.svg new file mode 100644 index 0000000..ee573f5 --- /dev/null +++ b/article-image_segmentation_in_radiology/src/figures/oHnJx7m981.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/src/figures/pgsAj00Hny.svg b/article-image_segmentation_in_radiology/src/figures/pgsAj00Hny.svg new file mode 100644 index 0000000..7740eb1 --- /dev/null +++ b/article-image_segmentation_in_radiology/src/figures/pgsAj00Hny.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/src/figures/rNbnzxfxV1.svg b/article-image_segmentation_in_radiology/src/figures/rNbnzxfxV1.svg new file mode 100644 index 0000000..78d07e0 --- /dev/null +++ b/article-image_segmentation_in_radiology/src/figures/rNbnzxfxV1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/article-image_segmentation_in_radiology/src/figures/results.png b/article-image_segmentation_in_radiology/src/figures/results.png new file mode 100644 index 0000000..f34599f Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/results.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/results_2.png b/article-image_segmentation_in_radiology/src/figures/results_2.png new file mode 100644 index 0000000..2447152 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/results_2.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/rgb_lab.png b/article-image_segmentation_in_radiology/src/figures/rgb_lab.png new file mode 100644 index 0000000..c17ea90 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/rgb_lab.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/trans_conv.png b/article-image_segmentation_in_radiology/src/figures/trans_conv.png new file mode 100644 index 0000000..f11c94c Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/trans_conv.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/unet.png b/article-image_segmentation_in_radiology/src/figures/unet.png new file mode 100644 index 0000000..312c59f Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/unet.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/unet_example.png b/article-image_segmentation_in_radiology/src/figures/unet_example.png new file mode 100644 index 0000000..4a1b2f5 Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/unet_example.png differ diff --git a/article-image_segmentation_in_radiology/src/figures/workflow.png b/article-image_segmentation_in_radiology/src/figures/workflow.png new file mode 100644 index 0000000..72633de Binary files /dev/null and b/article-image_segmentation_in_radiology/src/figures/workflow.png differ diff --git a/article-image_segmentation_in_radiology/src/main.py b/article-image_segmentation_in_radiology/src/main.py new file mode 100644 index 0000000..4c18bdc --- /dev/null +++ b/article-image_segmentation_in_radiology/src/main.py @@ -0,0 +1,89 @@ +import cv2 +import os +import matplotlib.pyplot as plt +import numpy as np + +script_path = os.path.abspath(__file__) +script_directory = os.path.dirname(script_path) +data_directory = os.path.join(script_directory, 'data') +masks_directory = os.path.join(data_directory, 'masks') + +masks_dict = {} +for filename in os.listdir(masks_directory): + if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.tiff')): + mask = cv2.imread(os.path.join(masks_directory, filename), cv2.IMREAD_GRAYSCALE) + mask_bin = (mask > 0).astype(np.uint8) + masks_dict[filename] = mask_bin + + + +clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8)) + +for filename in os.listdir(data_directory): + if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.tiff')): + + # Load images + img_rgb = cv2.imread(os.path.join(data_directory, filename)) + img_rgb = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2RGB) + + mask = cv2.imread(os.path.join(masks_directory, filename), cv2.IMREAD_GRAYSCALE) + mask_bin = (mask > 0).astype(np.uint8) + + # CLAHE on RGB + clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8)) + img_rgb_clahe = cv2.merge([ + clahe.apply(img_rgb[:, :, 0]), + clahe.apply(img_rgb[:, :, 1]), + clahe.apply(img_rgb[:, :, 2]) + ]) + + # LAB conversion + img_lab = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2LAB) + + l, a, b = cv2.split(img_lab) + l_clahe = clahe.apply(l) + img_lab_clahe = cv2.merge([l_clahe, a, b]) + + # Convert back to RGB for visualization + img_lab_rgb = cv2.cvtColor(img_lab, cv2.COLOR_LAB2RGB) + img_lab_clahe_rgb = cv2.cvtColor(img_lab_clahe, cv2.COLOR_LAB2RGB) + + # Gaussian Filter on CLAHE LAB + img_lab_clahe_gauss = cv2.GaussianBlur(img_lab_clahe, (5, 5), 0) + img_lab_clahe_gauss_rgb = cv2.cvtColor(img_lab_clahe_gauss, cv2.COLOR_LAB2RGB) + + # Create mask overlay + mask_colored = np.zeros_like(img_rgb) + mask_colored[:, :, 0] = mask_bin * 255 # red mask + + img_rgb_overlay = cv2.addWeighted(img_rgb, 0.7, mask_colored, 0.3, 0) + img_rgb_clahe_overlay = cv2.addWeighted(img_rgb_clahe, 0.7, mask_colored, 0.3, 0) + + img_lab_overlay = cv2.addWeighted(img_lab_rgb, 0.7, mask_colored, 0.3, 0) + img_lab_clahe_overlay = cv2.addWeighted(img_lab_clahe_rgb, 0.7, mask_colored, 0.3, 0) + img_lab_clahe_gauss_overlay = cv2.addWeighted(img_lab_clahe_gauss_rgb, 0.7, mask_colored, 0.3, 0) + + # Plot + fig, axes = plt.subplots(3, 5, figsize=(20, 10)) # 5 columns now + + # Row 1: Originals + axes[0, 0].imshow(img_rgb); axes[0, 0].set_title("Original RGB"); axes[0, 0].axis("off") + axes[0, 1].imshow(img_rgb_clahe); axes[0, 1].set_title("CLAHE on RGB"); axes[0, 1].axis("off") + axes[0, 2].imshow(img_lab_rgb); axes[0, 2].set_title("Original LAB (as RGB)"); axes[0, 2].axis("off") + axes[0, 3].imshow(img_lab_clahe_rgb); axes[0, 3].set_title("CLAHE on L (LAB)"); axes[0, 3].axis("off") + axes[0, 4].imshow(img_lab_clahe_gauss_rgb); axes[0, 4].set_title("Gaussian Filter (CLAHE LAB)"); axes[0, 4].axis("off") + + # Row 2: Masks + for j in range(5): + axes[1, j].imshow(mask, cmap="gray") + axes[1, j].set_title("Mask"); axes[1, j].axis("off") + + # Row 3: Overlays + axes[2, 0].imshow(img_rgb_overlay); axes[2, 0].set_title("Original + Mask"); axes[2, 0].axis("off") + axes[2, 1].imshow(img_rgb_clahe_overlay); axes[2, 1].set_title("CLAHE RGB + Mask"); axes[2, 1].axis("off") + axes[2, 2].imshow(img_lab_overlay); axes[2, 2].set_title("LAB + Mask"); axes[2, 2].axis("off") + axes[2, 3].imshow(img_lab_clahe_overlay); axes[2, 3].set_title("CLAHE LAB + Mask"); axes[2, 3].axis("off") + axes[2, 4].imshow(img_lab_clahe_gauss_overlay); axes[2, 4].set_title("Gaussian CLAHE LAB + Mask"); axes[2, 4].axis("off") + + plt.tight_layout() + plt.show() \ No newline at end of file