Colorectal Histology Image Classification

Classification of different types of colorectal cancer based on features Extracted by Texture Analysis.
60 Downloads
Updated 21 Nov 2021

View License

Colorectal Histology Image Classification-
clc;
clear all;
close all;
A = imread('adipose.tif');clc;
%OFFSET AND DIRECTION
Displacementx = -1;
Displacementy = 1;
As = (A-min(A(:)))+1;
NumQuantLevels = max(As(:));
glcm = zeros([NumQuantLevels,NumQuantLevels]);
if ( Displacementx < 0 )
sx=abs(Displacementx)+1;
ex=size(As,1);
else
sx=1;
ex=size(As,1)-Displacementx;
end
if ( Displacementy < 0 )
sy=abs(Displacementy)+1;
ey=size(As,2);
else
sy=1;
ey =size(As,2)-Displacementy;
end
for i=sx:ex
for j=sy:ey
glcm(As(i,j),As(i+(1*Displacementx),j+(1*Displacementy)))=glcm(As(i,j),As(i+(1*Displacementx),j+(1*Displacementy)))+1;
end
end
GLCMProb = glcm./sum(glcm(:));
[jj,ii]=meshgrid(1:size(glcm,1),1:size(glcm,2));
ij=ii-jj;
Con = sum(sum(GLCMProb.*(ij).^2));
Diss = sum(sum(GLCMProb.*abs(ij)));
Hom = sum(sum(GLCMProb./(1+(ij).^2)));
Asm = sum(sum(GLCMProb.^2));
Meanx = sum(sum(GLCMProb.*ii));
Meany = sum(sum(GLCMProb.*jj));
Energy = sqrt(Asm);
MaxGLCM = max(GLCMProb(:));
Entropy = sum(sum(-GLCMProb .* log10(GLCMProb+0.00001)));
GLCMMean = (Meanx+Meany)/2;
Varx = sum(sum(GLCMProb.*(ii-Meanx).^2));
Vary = sum(sum(GLCMProb.*(jj-Meany).^2));
GLCMVar = (Varx+Vary)/2;
GLCMCorrelation = sum(sum(GLCMProb.*(ii-Meanx).*(jj-Meany)/sqrt(Varx*Vary)));
CG=sprintf("Contrast Group:\nContrast:%f\nDissimilarity:%f\nHomogeneity:%f\n",Con,Diss,Hom);
OG=sprintf("Orderliness Group:\nAngular Second Moment :%f\nMax Probability:%f\nEntropy:%f\nEnergy:%f\n",Asm,MaxGLCM,Entropy,Energy);
SG=sprintf("Statistics Group:\nGLCM Mean:%f\nGLCM Variance:%f\nGLCM Correlation:%f\n",GLCMMean,GLCMVar,GLCMCorrelation);
display(CG);
display(OG);
display(SG);
%Classification
if (((50<GLCMMean)&&(GLCMMean<109))&&(GLCMVar<30))
disp('Input image is of Empty class.')
elseif(((50<GLCMMean)&&(GLCMMean<109))&&((1500<GLCMVar)&&(GLCMVar<6000)))
disp('Input image is of Lympho class.')
elseif(GLCMMean>179)
disp('Input image is of Adipose class.')
elseif((110<GLCMMean)&&(GLCMMean<135))
disp('Input image is of Tumor class.')
elseif (((130<GLCMMean)&&(GLCMMean<180))&&((1000<GLCMVar)&&(GLCMVar<1400)))
disp('Input image is of stroma class.')
elseif (((130<GLCMMean)&&(GLCMMean<180))&&(GLCMVar>1401))
disp('Input image is of Complex class.')
else
disp('Input image is of some other class.')
end
Visual Representation-
Here, the first 10 images of every tissue class in the dataset are shown. They represent the wide variation of illumination, stain intensity and tissue textures present in routine histopathological images. Images were extracted from 10 independent samples of colorectal cancer (CRC) primary tumours. (a) tumour epithelium, (b) simple stroma, (c) complex stroma (stroma that contains single tumour cells and/or single immune cells), (d) immune cell conglomerates, (e) debris and mucus, (f) mucosal glands, (g) adipose tissue, (h) background.
DataSet has been taken from-https://zenodo.org/record/53169#.W6HwwP4zbOQ
Method-
Feature Extraction by Texture Analysis and Image Classification Based on Features.
Step1:Color Transformation is Used.
Step2: Texture Analysis
1_GLCM method has been used .
2_Following Features has been calculated.
Contrast Group:
  • Contrast (Con)
  • Dissimilarity (Diss)
  • Homogeneity (Hom)
Orderliness Group:
  • Angular Second Moment (Asm)
  • Maximum Probability (Max)
  • Entropy (Entropy)
Statistics Group:
  • GLCM Mean
  • GLCM Variance
  • GLCM Correlation
Step3: Classification based on Prominent features values & classified as per different types
Result- On the basis of feature extracted from texture analysis the Image has been Classified .

Cite As

TUSHAR MAHORE (2024). Colorectal Histology Image Classification (https://www.mathworks.com/matlabcentral/fileexchange/102434-colorectal-histology-image-classification), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0