首页 > 行业资讯 > 【水果识别】基于计算机视觉实现橙子数量识别含Matlab源码

【水果识别】基于计算机视觉实现橙子数量识别含Matlab源码

时间:2023-01-09 来源: 浏览:

【水果识别】基于计算机视觉实现橙子数量识别含Matlab源码

天天Matlab 天天Matlab
天天Matlab

TT_Matlab

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,完整matlab代码或者程序定制加qq1575304183。

收录于合集 #图像处理matlab源码 913个

1 简介

在现实生活中成人识别水果是十分简易的但对于幼儿来说在没有实物之前是无法识别水果的,因此本文设计了一个简易水果识别系统为幼儿在电子设备上识别水果提供可能.本文通过matlab GUI设计了一个水果识别系统界面并通过对水果图像进行二值化处理,边缘处理最后实现了橙子数量识别.

2 部分代码

function [t,em] = otsuthresh(counts) %#codegen % OTSUTHRESH Global histogram threshold using Otsu ’s method - M-to-C codegen. % Copyright 2015 The MathWorks, Inc. % Syntax % ------ % % [t,em] = otsuthresh(counts) % % Input Specs % ----------- % % counts: % numeric % vector % real % finite % non-sparse % non-negative % % Output Specs % ------------ % % t: % scalar % double % in [0,1] % % em: % scalar % double % in [0,1] % % Validate counts validateattributes(counts,{’numeric’}, ... {’vector’,’real’,’finite’,’nonsparse’,’nonnegative’},mfilename,’COUNTS’); % Number of bins num_bins = numel(counts); % Number of elements num_elems = 0; for k = 1:num_bins num_elems = num_elems + double(counts(k)); end % CDF of the histogram omega = coder.nullcopy(zeros(num_bins,1)); omega(1) = double(counts(1))/num_elems; mu = coder.nullcopy(zeros(num_bins,1)); mu(1) = omega(1); for k = 2:num_bins % PDF p = double(counts(k))/num_elems; % CDF omega(k) = omega(k-1) + p; % "weighted" CDF mu(k) = mu(k-1) + p*k; end mu_t = mu(end); % Equation 18 in the paper sigma_b_squared = coder.nullcopy(zeros(num_bins,1)); maxval = -coder.internal.inf; for k = 1:num_bins sigma_b_squared(k) = (mu_t*omega(k) - mu(k))^2 / (omega(k)*(1-omega(k))); maxval = max(maxval,sigma_b_squared(k)); end % Find the location of the maximum value of sigma_b_squared. % If maxval is NaN, meaning that sigma_b_squared % is all NaN, then return 0. isfinite_maxval = isfinite(maxval); if isfinite_maxval % The maximum may extend over several bins, % so average together the locations. idx = double(0); num_maxval = double(0); for k = 1:num_bins idx = idx + k * double(sigma_b_squared(k) == maxval); num_maxval = num_maxval + 1 * double(sigma_b_squared(k) == maxval); end idx = idx / num_maxval; % Normalize the threshold to the range [0,1] t = (idx - 1) / (num_bins - 1); else t = 0; end % Compute the effectiveness metric if nargout > 1 if isfinite_maxval d = 0; for k = 1:num_bins d = d + double(counts(k))/num_elems * k^2; end em = maxval/(d - mu_t^2); else em = 0; end end

3 仿真结果

4 参考文献

[1]阳江平. 基于计算机视觉的果蔬识别方法研究[D]. 大连理工大学.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

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

版权:如无特殊注明,文章转载自网络,侵权请联系cnmhg168#163.com删除!文件均为网友上传,仅供研究和学习使用,务必24小时内删除。
相关推荐