%% 一、病斑识别与分割代码
% 作者:小洋葱
%% 病害识别
clear;clc;
RGB=imread('病害图片.jpg');
subplot(221);imshow(RGB);title('原始图像');
dRGB = im2double(RGB); %图像运算不能用uint8类型,会发生溢出现象,要转成double类型
R = dRGB(:,:,1);
G = dRGB(:,:,2);
B = dRGB(:,:,3);
%% 灰度化
E = 2*G-R-B;
[m,n] = size(E);
T = graythresh(E);%灰度阈值
subplot(222);imshow(E);title('灰度图像');
%% 二值化
BW1 = imbinarize(E,T);
BW2 = ~BW1 ;
subplot(223);imshow(BW2);title('二值图像');
BW3= bwareaopen(BW2,20,8);
subplot(224);imshow(BW3);title('去噪图像');
%% 统计病害面积
TotalArea = m*n
DiseaseArea = bwarea(BW3)
Percent = string(round(DiseaseArea/TotalArea,4)*100)+"%"
基于MATLAB的叶片病害识别与分割代码(简单版)
需积分: 5 88 浏览量
2023-07-26
19:56:11
上传
评论 2
收藏 11KB ZIP 举报
小洋葱.
- 粉丝: 186
- 资源: 23