【水果质量检测】基于机器视觉实现苹果疾病识别分类附matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测 雷达通信  无线传感器

信号处理 图像处理 路径规划 元胞自动机 无人机  电力系统

⛄ 内容介绍

苹果梗蒂和缺陷的识别是苹果自动检测中的难点,两者的误分类会造成苹果质量等级的误判.介绍了一个基于机器视觉的苹果质量自动评价系统.通过梗蒂识别,缺陷分割,确定缺陷区域并移除梗蒂区域,形成新的兴趣区域;提取统计,纹理和几何特征,采用Pearson特征相关性分析和SFFS特征选择,删除冗余特征;采用模糊KNN分类器在富士苹果进行试验,得到的平均识别正确率为83%.这项技术可以用于苹果包装流水线作业,也可用于类似的农产品外观质量检测.

⛄ 部分代码

%XYZ = rgb2xyz(RGB)

%

%Output parameter: RGB must be an image having 3 channels, i.e. a 3D array.

%   Each channel of RGB should be in the range 0..255.

%Input parameter: XYZ would be an image of the same dimension.

%

%Example: To convert an image in RGB format to L*a*b* format, one can

%combine the calling to the rgb2xyz and xyz2lab functions:

%   rgbim = imread('yourImage.png');  % image in RGB format

%   labim = xyz2lab(rgb2xyz(rgbim));

%The output labim has the following ranges of values:

%  - first channel L*       0..100

%  - the second channel a*  -128..127

%  - the third channel b    -128..127

%Other software packages, e.g. OpenCV, often applies a normalisation

%process so that images in the L*a*b* format can be stored as 3-channel

%greyscale images. The normalisation adopted by OpenCV is:

%  - the first channel L* is rescaled to the range 0..255. This can be done

%    easily by multiplying by 255 and dividing by 100.

%  - the second channel a* and third channel b* are added by 128 to bring

%    the range from -128..127 to 0..255.

%

%When comparing the pixel values of an L*a*b* image produced by the Matlab

%function here and those from OpenCV, ensure that the above normalisation

%procedure is taken into account.

%

%Also noted that images that are read from disk into OpenCV have their

%channels specified in reverse order in the data structure. So, to compare

%the Matlab function here with those in OpenCV, use the following OpenCV

%functions:

%   source_rgb_image = cvLoadImage('yourImage.png', 1);

%   // make sure that the 3rd parameter is CV_BGR2Lab and not CV_RGB2Lab

%   cvCvtColor(source_rgb_image, destination_lab_image, CV_BGR2Lab);

%   // the resultant L*a*b* image is created within the program (i.e. not

%   // read from disk), so the channels are in the right order:

%   cvCvtPixToPlane(destination_lab_image, l_channel, a_channel, b_channel,

%                   0);

%

%References:

%* http://www.easyrgb.com/index.php?X=MATH

%* http://en.wikipedia.org/wiki/SRGB_color_space

%

%SEE ALSO

%  xyz2rgb, xyz2lab, lab2xyz

%

%Feb 2010

%

%Copyright Du Huynh

%School of Computer Science and Software Engineering

%The University of Western Australia

RGB = RGB/255;

index1 = find(RGB > 0.04045);

index2 = find(RGB <= 0.04045);

RGB(index1) = ((RGB(index1) + 0.055) / 1.055).^2.4;

RGB(index2) = RGB(index2) / 12.92;

%Observer. = 2°, Illuminant = D65

XYZ = zeros(size(RGB));

M =  [

    0.4124  0.3576  0.1805;

    0.2126  0.7152  0.0722;

    0.0193  0.1192  0.9505

    ];

for i=1:3

    XYZ(:,:,i) = RGB(:,:,1)*M(i,1) + RGB(:,:,2)*M(i,2) + RGB(:,:,3)*M(i,3);

end

XYZ = XYZ*100;

end

⛄ 运行结果

⛄ 参考文献

[1]蒋益女, 徐从富. 基于机器视觉的苹果质量等级识别方法的研究[J]. 计算机应用与软件, 2010, 27(11):3.

[2]童旭. 基于机器视觉水果表面等级分类识别的研究[D]. 重庆交通大学, 2018.

⛄ 完整代码

❤️部分理论引用网络文献,若有侵权联系博主删除

❤️ 关注我领取海量matlab电子书和数学建模资料

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值