Skip to content

Instantly share code, notes, and snippets.

View jnkather's full-sized avatar

Jakob Nikolas Kather jnkather

View GitHub Profile
@odebeir
odebeir / gist:5038467
Last active April 1, 2016 23:10
Color deconvolution for python cf : A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution.,” Analytical and quantitative cytology and histology / the International Academy of Cytology [and] American Society of Cytology, vol. 23, no. 4, pp. 291–9, Aug. 2001.
def convert_to_optical_densities(rgb,r0,g0,b0):
OD = rgb.astype(float)
OD[:,:,0] /= r0
OD[:,:,1] /= g0
OD[:,:,2] /= b0
return -np.log(OD)
def color_deconvolution(rgb,r0,g0,b0,verbose=False):
stain_OD = np.asarray([[0.18,0.20,0.08],[0.01,0.13,0.0166],[0.10,0.21,0.29]]) #hematoxylin, eosyn, DAB