Giter VIP home page Giter VIP logo

henorm_python's Introduction

Modifications:

  • H&E normalization optimized for speed and multiprocessing - June '19 Joni Juvonen
  • Speed optimization (~8x speed improvements) - June '19 Mikko
  • H&E Stain augmentor - August '19 Joni Juvonen

H&E stain augmentation

Randomize staining appearance for H&E stained images.

Example usage:

import stainAugmentation
import cv2

original_image = cv2.cvtColor(cv2.imread('imgs/example1.png'), cv2.COLOR_BGR2RGB)
augmented_image = stainAugmentation.randomHEStaining(original_image)

Random H&E augmentations

H&E augmentations

How to use this as a Fastai transform

import PIL
import numpy as np
import stainAugmentation

def _HEaugment(x):
    img = PIL.Image.fromarray(image2np(x*255).astype('uint8'))
    x = stainAugmentation.randomHEStaining(img)
    x = pil2tensor(x/255.,np.float32)
    return x

HEaugment = TfmPixel(_HEaugment)

Now, HEaugment() can be passed to transformations list: tfms = [HEaugment()]


Staining Unmixing and Normalization in Python

NOTE: Originally published at the Assessment of Mitosis Detection Algorithms 2013 challenge website (http://http://amida13.isi.uu.nl).

Adapted from original implementation (https://github.com/mitkovetta/staining-normalization).

One of the major difficulties in histopathology image analysis is apperance variability. For example, when performing mitosis detection, many false positives can arise when the histopathology slide is overstained. This Python code, adapted from the original MATLAB implementation, performs staining unmixing (separation of the hematoxylin and eosing stains) and apperance normalization. It is based on the method described in [1]. Some examples of staining normalization can be seen in the figure below.

[1] A method for normalizing histology slides for quantitative analysis, M Macenko, M Niethammer, JS Marron, D Borland, JT Woosley, G Xiaojun, C Schmitt, NE Thomas, IEEE ISBI, 2009. dx.doi.org/10.1109/ISBI.2009.5193250

First, compile cython binaries: run python ./setup.py build_ext --inplace

Examples

Original Images

Normalized Images

Stain Unmixing

Example 1

Example 2

henorm_python's People

Contributors

schaugf avatar jpjuvo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.