Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a50dc37
feat: add image segmentation in radiology article and source files
Ghenntoggy1 Sep 6, 2025
781a3f4
docs: change title of the article
Ghenntoggy1 Sep 6, 2025
0599c04
docs: add author section
Ghenntoggy1 Sep 6, 2025
5e1710d
docs: convey to academic writing
Ghenntoggy1 Sep 6, 2025
65a560c
fix(style): align figcaption below image in figure element
Ghenntoggy1 Sep 6, 2025
389b64d
fix(style): delete comments from style block
Ghenntoggy1 Sep 6, 2025
c8aa14f
fix(style): place style block at the top of the markdown file.
Ghenntoggy1 Sep 6, 2025
826bc8a
fix(style): replace style block-approach with inline styling
Ghenntoggy1 Sep 6, 2025
7f14263
fix(figure): Wrap figure in <p> block
Ghenntoggy1 Sep 6, 2025
7cd95fb
Revert "fix(figure): Wrap figure in <p> block"
Ghenntoggy1 Sep 6, 2025
fee92fb
fix(figure): Change style for first figure
Ghenntoggy1 Sep 6, 2025
c24fdbc
fix(figure): Add background to first figure
Ghenntoggy1 Sep 6, 2025
f377924
fix(figures): center figures and captions
Ghenntoggy1 Sep 6, 2025
b96233b
fix(figure): change figure number to the order
Ghenntoggy1 Sep 6, 2025
69fa331
fix(figure): use table for side-by-side images
Ghenntoggy1 Sep 6, 2025
3f327a6
fix(): center tables. use markdown math for equations
Ghenntoggy1 Sep 6, 2025
8879a54
fix(math): close math block
Ghenntoggy1 Sep 6, 2025
0e53dfd
fix(math): delete new line before enclosing gathering block
Ghenntoggy1 Sep 6, 2025
18c2740
fix(math): use aligned instead of gathered
Ghenntoggy1 Sep 6, 2025
ce3d0ba
fix(math): switch to github markdown math block
Ghenntoggy1 Sep 6, 2025
ce2f19e
fix(math): try with gathered
Ghenntoggy1 Sep 6, 2025
5a6c00a
Revert "fix(math): try with gathered"
Ghenntoggy1 Sep 6, 2025
cf5d12c
fix(math): multiple-lines equations converted to remote image
Ghenntoggy1 Sep 6, 2025
a83b54e
Revert "fix(math): multiple-lines equations converted to remote image"
Ghenntoggy1 Sep 6, 2025
39dd903
fix(math): use local svg for multiple-lines equations
Ghenntoggy1 Sep 6, 2025
b13021e
docs: add link to latex pdf version of the article
Ghenntoggy1 Sep 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions article-image_segmentation_in_radiology/README.md
Original file line number Diff line number Diff line change
@@ -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 "<path/to/file>"
```

## 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.
1,231 changes: 1,231 additions & 0 deletions article-image_segmentation_in_radiology/article.md

Large diffs are not rendered by default.

Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions article-image_segmentation_in_radiology/src/main.py
Original file line number Diff line number Diff line change
@@ -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()
Loading