ntfs格式分区
图像⼆值化-MATLAB实现1.图像⼆值化代码:A=imread('hw1.chips1.GIF'); %读取到⼀张图⽚
%thresh = graythresh(A); %⾃动确定⼆值化阈值
I2 = im2bw(A,120/255); %对图像⼆值化
figure();
subplot(1,2,1);
imshow(A); %显⽰⼆值化之前的图⽚
title('原图');
phc管桩subplot(1,2,2);
imshow(I2); %显⽰⼆值化之后的图⽚
title('⼆值化');
oriImg = imread('hw1.chips1.GIF');
grayImg = oriImg;
%grayImg = rgb2gray(oriImg); %转换为灰度图
grayImg = double(grayImg);
[m, n] = size(oriImg);
foreCount = 0;
foreTotal = 0;
backCount = 0;
backTotal = 0;
for x = 1:m
for y = 1:n
if(grayImg(x,y) >= 128)
foreCount = foreCount + 1;
foreTotal = foreTotal + grayImg(x,y);
else
backCount = backCount + 1;
backTotal = backTotal + grayImg(x,y);
end
end
end
backMean = backTotal / backCount;
foreMean = foreTotal / foreCount;
backSqu = 0;pc133
foreSqu = 0;
for x =1:m
for y = 1:n
if(grayImg(x,y) >= 128)
foreSqu = foreSqu + (grayImg(x,y) - foreMean)^2;
else
backSqu = backSqu + (grayImg(x,y) - backMean)^2;
end
end
end
backSqu = sqrt(backSqu / backTotal);
foreSqu = sqrt(foreSqu / foreTotal);
disp(strcat('背景均值', num2str(backMean)));
一江春水向东流任正非
disp(strcat('背景标准差', num2str(backSqu)));
disp(strcat('前景均值', num2str(foreMean)));
disp(strcat('前景标准差', num2str(foreSqu)));
3.求⽬标和背景⾼斯分布(双峰直⽅图)
x = 0:0.1:256;北京个别患者出现非典型症状
y1 = gaussmf(x,[backSqu^2 backMean]); plot(x, y1);
hold on;
y2 = gaussmf(x,[foreSqu^2 foreMean]); plot(x, y2);复旦求是三校生高复
title('⾼斯分布');