資源簡(jiǎn)介
基于matlab的癌細(xì)胞的識(shí)別與定位的代碼實(shí)現(xiàn)基于matlab的癌細(xì)胞的識(shí)別與定位的代碼實(shí)現(xiàn)
代碼片段和文件信息
I=imread(‘C:\cancer.bmp‘);%%讀圖像
I=I(::1);
figure(1)
subplot(121)
imshow(I)
title(‘原圖像‘)
subplot(122)
imhist(I)
I2=histeq(I);
figure(2)
subplot(121)
imshow(I2)
title(‘直方圖均衡化‘)
subplot(122)
imhist(I2)
[mn]=size(I2);
I1=double(I2);%歸一化
M0=150;var0=200;
M?=?0?;?var?=?0;?%%M為原圖像的均值,var為方差,先進(jìn)行初始化0
M=double(M);
var=double(var);
for?x?=?1?:?m
????for?y?=?1?:?n
????????M?=?M?+?I1(xy);?%%求所有像素的灰度和
????end
end
M=M/(m*n);??%%M1整幅圖像的灰度均值
for?x=1:m
????for?y=1:n
????????var=var+(I1(xy)-M).^2;
????end
end
var=var/(m*n);??%%var1整幅圖像的方差
for?x=1:m?????%%使用歸一化的公式進(jìn)行計(jì)算?
????for?y=1:n
????????if?I1(xy)>=M???%%如果大于均值
????????????I1(xy)=M0+sqrt(var0*((I1(xy)-M).^2)/var);
????????
????????else
????????????I1(xy)=M0-sqrt(var0*((M-I1(xy)).^2)/var);
????????end
????end
end
Igrey?=?uint8(I1*255);
figure(3);subplot(121);imshow(I);title(‘均衡化后圖像‘)
subplot(122);imshow(uint8(I1));title(‘歸一化后的圖像‘)
[xy]=size(I);
for?i=1:x???
?????for?j?=1:y
????????if(I(ij)>105)
????????????I(ij)=1;
????????else
????????????I(ij)=0;
????????end;
?????end
end
??
clc;
G=imread(‘C:\cancer.bmp‘);%%讀圖像
I=rgb2gray(G);
[xy]=size(I);
BW=bwperim(I8);
P1=0;
P2=0;
Ny=0;
for?i=1:x
????for?j=1:y
????????if(BW(ij)>0)
????????????P2=j;
????????????if((P2-P1)==1)
????????????????Ny=Ny+1;
????????????end
????????????P1=P2;
????????end?
????end
end
P1=0;
P2=0;
Nx=0;
for?j=1:y
????for?i=1:x
????????if(BW(ij)>0)
????????????P2=i;
????????????if((P2-P1)==1)
?
評(píng)論
共有 條評(píng)論