-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcancer_detect.m
58 lines (42 loc) · 1.12 KB
/
cancer_detect.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
clc;close all;clear all;
I=imread('F2.jpg');
I=imresize(I,[200,300]);
size(I)
figure
imshow(I)
rgb = imopen(I,strel('disk',1));
figure;
imshow(rgb);
title('background')
gray_image = rgb2gray(rgb);
imshow(gray_image);
[centers, radii] = imfindcircles(rgb,[2 80],'ObjectPolarity','dark','Sensitivity',0.9)
imshow(rgb);
cell = length(centers)
M = mean(radii)
max = max(radii)
h = viscircles(centers,radii)
red=rgb(:,:,1);green= rgb(:,:,2); blue= rgb(:,:,3);
out=red>25 & red<199 &green<130 & blue>140 & blue<225;
out1=imfill(out,'holes');
out2=bwmorph(out1,'erode');
out3=bwmorph(out2,'dilate',1.2);
out3=imfill(out3,'holes');
out3=bwareaopen(out3,100);
figure;
imshow(out3);
title('Cancer cells')
out3=im2bw(out3);
[l,NUM]=bwlabel(out3,4);
cancer=(NUM/cell)*100;
disp('Myeloid cells percentage is')
disp(cancer);
if cancer<0.8
disp('Healthy. No Problem');
elseif cancer<1 & cancer>0.5
disp('High myeloid cell concentration.');
elseif cancer > 1 & cancer < 8
disp('Initial Stage Leukemia');
elseif cancer > 8
disp('Advanced Stage Leukemia');
end