
Project Computer Vision – Image Analysis and Enhancement of Histopathology Slides



Stain de-convolution
Method 1 : least square fitting
Solve the linear equation Ax = b,
where A is the estimated stain vectors, b is optical density(OD).
# Method 1 : least squared fitting A = stainVectors.T b = np.reshape(OD,(ROI_height*ROI_width,3)).T x, _, _, _ = np.linalg.lstsq(A,b) hema_lstsq = np.reshape(x[0,:],(ROI_height,ROI_width)) eosin_lstsq = np.reshape(x[1,:],(ROI_height,ROI_width))
Method 2 : Moore-Penrose pseudo-inverse
# Method 2 : Moore-Penrose pseudoinverse inv_matx = np.linalg.pinv(np.dot(stainVectors,stainVectors.T)) result = np.dot(np.dot(OD,stainVectors.T),inv_matx) hema = result[:,:,0] eosin =result[:,:,1]


Reference
https://towardsdatascience.com/stain-estimation-on-microscopy-whole-slide-images-2b5a57062268
https://towardsdatascience.com/microscopy-stain-variations-and-how-to-estimate-them-baca29f57ee9