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