Skip to content

Latest commit

Β 

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧬 Adaptive Unsharpening for Blood Cell Analysis

MATLAB and PyTorch implementations of adaptive focus-aware image enhancement and deep learning for blood-cell classification

MATLAB PyTorch Python License: GPL v3 Paper Project Page

Source code for the ICASSP 2021 paper
Acute Lymphoblastic Leukemia Detection Based on Adaptive Unsharpening and Deep Learning


🧠 Overview

This repository contains the original MATLAB implementation and a newer Python/PyTorch implementation of the adaptive unsharpening framework introduced in our ICASSP 2021 paper.

The method improves microscopic blood-cell images before classification by combining:

  • focus-quality estimation;
  • adaptive unsharp masking;
  • VAR-PCANet / PCANet-based parameter tuning;
  • pretrained deep CNNs and fine-tuning;
  • classification and explainability analysis.

The original work was developed for Acute Lymphoblastic Leukemia (ALL) detection on ALL-IDB2. The PyTorch implementation additionally supports a modern GPU-oriented workflow and experiments on RAABIN-WBC.


✨ Original vs Adaptive Unsharpening

The adaptive preprocessing increases local detail while preserving the underlying cell morphology.

RAABIN-WBC original vs adaptive unsharpening ALL-IDB2 original vs adaptive unsharpening

Example comparison on RAABIN-WBC and ALL-IDB2. Each original image is paired with the corresponding adaptively unsharpened version.


πŸ”¬ Method at a Glance

Microscopic blood-cell images
        β”‚
        β–Ό
Focus-quality estimation
        β”‚
        β–Ό
Adaptive unsharpening
        β”‚
        β–Ό
VAR-PCANet / PCANet parameter tuning
        β”‚
        β–Ό
Deep CNN feature extraction / fine-tuning
        β”‚
        β–Ό
Classification
        β”‚
        β–Ό
Blood-cell / leukemia prediction

The key idea is to adapt the amount of sharpening to the estimated focus quality of each image instead of applying a fixed sharpening strength to the entire dataset.


πŸ“ Repository Structure

.
β”œβ”€β”€ imgs/                       # README figures / example outputs
β”‚
β”œβ”€β”€ Matlab/                     # Original MATLAB implementation
β”‚   β”œβ”€β”€ functions/
β”‚   β”‚   β”œβ”€β”€ functions_Classifiers/
β”‚   β”‚   β”œβ”€β”€ functions_DBProc/
β”‚   β”‚   β”œβ”€β”€ functions_ellipse/
β”‚   β”‚   β”œβ”€β”€ functions_FeatExtr/
β”‚   β”‚   β”œβ”€β”€ functions_Freq/
β”‚   β”‚   β”œβ”€β”€ functions_Gabor/
β”‚   β”‚   β”œβ”€β”€ functions_Kovesi/
β”‚   β”‚   β”œβ”€β”€ functions_Orient/
β”‚   β”‚   β”œβ”€β”€ functions_PCANet/
β”‚   β”‚   β”œβ”€β”€ functions_preProc/
β”‚   β”‚   └── functions_Reconstruct/
β”‚   β”œβ”€β”€ libraries/
β”‚   β”‚   β”œβ”€β”€ lib_1Shot-MaxPol/
β”‚   β”‚   β”œβ”€β”€ lib_colorNorm/
β”‚   β”‚   β”œβ”€β”€ lib_FastCMeans/
β”‚   β”‚   β”œβ”€β”€ lib_FQPath/
β”‚   β”‚   └── lib_StainDeconv/
β”‚   β”œβ”€β”€ params/
β”‚   β”œβ”€β”€ steps/
β”‚   └── util/
β”‚
└── PyTorch/                    # GPU-oriented Python/PyTorch implementation
    β”œβ”€β”€ configs/
    β”œβ”€β”€ imgs/
    β”œβ”€β”€ scripts/
    β”œβ”€β”€ src/
    β”‚   └── cnn_all/
    β”‚       β”œβ”€β”€ classifiers/
    β”‚       β”œβ”€β”€ cnn/
    β”‚       β”œβ”€β”€ data/
    β”‚       β”œβ”€β”€ focus/
    β”‚       β”œβ”€β”€ legacy/
    β”‚       β”œβ”€β”€ pcanet/
    β”‚       └── pipeline/
    └── tests/

MATLAB Version

πŸš€ MATLAB Setup

The MATLAB implementation contains the original processing pipeline used for the ICASSP 2021 work.

Requirements

Typical components include:

  • Deep Learning Toolbox
  • Image Processing Toolbox
  • Statistics and Machine Learning Toolbox
  • Parallel Computing Toolbox

The repository also contains the external/supporting libraries used by the original pipeline.

Run

Open MATLAB from the repository root, move to:

Matlab/

and run:

launch_CNN_ALL

For the newer RAABIN-WBC adaptation, use the corresponding RAABIN launcher if present in your branch.


Python / PyTorch Version

⚑ GPU-Oriented Reimplementation

The PyTorch/ directory contains a modernized implementation designed for GPU execution.

The PyTorch version includes:

  • automatic dataset/class discovery;
  • focus-score caching;
  • adaptive unsharpening;
  • GPU PCANet / PCA operations;
  • pretrained CNN feature extraction;
  • CNN fine-tuning;
  • k-NN classification;
  • CMC and classification metrics;
  • Grad-CAM;
  • checkpointing and resume support;
  • standalone export of the unsharpened dataset.

The shared preprocessing/focus-tuning stage is computed once and reused across CNN backbones, avoiding unnecessary repeated computation.

🐍 Installation

cd PyTorch

python3 -m venv .venv
source .venv/bin/activate

python -m pip install --upgrade pip setuptools wheel

Install a CUDA-enabled PyTorch build appropriate for your system, then install the project:

pip install -e .

Verify the installation:

cnn-all doctor

πŸ“‚ Dataset Structure

RAABIN-WBC

PyTorch/
└── imgs/
    └── orig/
        └── Raabin-WBC/
            β”œβ”€β”€ Basophil/
            β”œβ”€β”€ Eosinophil/
            β”œβ”€β”€ Lymphocyte/
            β”œβ”€β”€ Monocyte/
            └── Neutrophil/

ALL-IDB2

ALL_IDB2/
β”œβ”€β”€ 0/
└── 1/

with:

0 -> Healthy
1 -> Lymphoblast

Dataset paths and experiment settings are configured through YAML files in:

PyTorch/configs/

▢️ Running the PyTorch Pipeline

From the PyTorch/ directory:

source .venv/bin/activate

Run the full pipeline:

cnn-all run --config configs/raabin_wbc.yaml

Or run it phase-by-phase:

cnn-all prepare --config configs/raabin_wbc.yaml
cnn-all focus-cache --config configs/raabin_wbc.yaml
cnn-all shared --config configs/raabin_wbc.yaml
cnn-all networks --config configs/raabin_wbc.yaml
cnn-all export --config configs/raabin_wbc.yaml

For remote execution:

nohup cnn-all run --config configs/raabin_wbc.yaml > raabin_run.log 2>&1 &

Monitor with:

tail -f raabin_run.log

πŸ§ͺ Supported CNN Backbones

The current PyTorch implementation supports:

  • AlexNet
  • VGG16
  • VGG19
  • ResNet18
  • ResNet50
  • ResNet101
  • DenseNet201

The same original and adaptively unsharpened train/test splits can be reused across all backbones for a fair comparison.


πŸ“Š Expected Outputs

Output Description
Classification results Accuracy and related classification metrics
Original vs unsharp comparison Evaluation on the two image versions
Focus statistics Focus-quality values and selected thresholds
PCANet features Learned PCA filters and feature representations
Trained CNNs Fine-tuned network checkpoints
Grad-CAM maps Visual explanation of CNN predictions
Logs Experiment logs and configuration information
Exported database Standalone adaptively unsharpened dataset

🧩 Included and Related Libraries

The MATLAB implementation includes or builds upon code and concepts from:

  • PCANet
    T. Chan, K. Jia, S. Gao, J. Lu, Z. Zeng, and Y. Ma,
    PCANet: A Simple Deep Learning Baseline for Image Classification?
    IEEE Transactions on Image Processing, 2015.

  • 1Shot-MaxPol
    M. S. Hosseini and K. N. Plataniotis,
    Convolutional Deblurring for Natural Imaging,
    IEEE Transactions on Image Processing, 2019.

  • FQPath
    M. S. Hosseini et al.,
    Focus Quality Assessment of High-Throughput Whole Slide Imaging in Digital Pathology,
    IEEE Transactions on Medical Imaging, 2020.

  • Fast N-D Grayscale Image Segmentation with c-/Fuzzy c-Means

  • Stain Deconvolution / SCD_FastICA

  • Comprehensive Colour Image Normalization
    G. Finlayson, B. Schiele, and J. L. Crowley, ECCV 1998.


πŸ“š Paper

If you use this code, please cite:

@InProceedings{icassp21,
  author    = {A. Genovese and M. S. Hosseini and V. Piuri and K. N. Plataniotis and F. Scotti},
  title     = {Acute Lymphoblastic Leukemia Detection Based on Adaptive Unsharpening and Deep Learning},
  booktitle = {Proc. of the 2021 IEEE Int. Conf. on Acoustics, Speech, and Signal Processing (ICASSP 2021)},
  address   = {Toronto, ON, Canada},
  pages     = {1205--1209},
  month     = {June},
  day       = {6--11},
  year      = {2021},
  note      = {ISBN: 978-1-7281-7605-5. DOI: 10.1109/ICASSP39728.2021.9414362}
}

Paper:

https://ieeexplore.ieee.org/document/9414362

Project page:

https://iebil.di.unimi.it/cnnALL/index.htm

πŸ‘₯ Authors

  • Angelo Genovese
    Department of Computer Science, UniversitΓ  degli Studi di Milano, Italy

  • Mahdi S. Hosseini

  • Vincenzo Piuri
    Department of Computer Science, UniversitΓ  degli Studi di Milano, Italy

  • Konstantinos N. Plataniotis
    Department of Electrical and Computer Engineering, University of Toronto, Canada

  • Fabio Scotti
    Department of Computer Science, UniversitΓ  degli Studi di Milano, Italy


πŸ“„ License

This project is released under the GNU General Public License v3.0.

See the LICENSE file for details.

About

Source code for the 2021 ICASSP paper "Acute Lymphoblastic Leukemia detection based on adaptive unsharpening and Deep Learning"

Topics

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages