function  bc = binary_conversion(a)  %这是灰度值二值化转换函数,阈值为平均值
j=imread(a);             %读取灰度图像  
j=double(j);             %将图像转换为小数浮点型(double)
[m,n]=size(j);             %获取图像的长宽(m,n)
s=sum(sum(j));             %图像像素值求和
a=s/(m*n);                  %计算像素平均值
a=round(a);                 %平均值去整
i=j>a;
bc=uint8(round(i*255));     %暗值赋0,亮值赋255
%imshow(bc);