当前位置 : 主页 > 编程语言 > python >

【大米粒计数】基于计算机视觉实现大米粒颗粒识别含Matlab源码

来源:互联网 收集:自由互联 发布时间:2022-06-15
1 简介 大米是人类的主食之一,是稻谷经清理、砻谷、碾米、成品整理等工序后制成的成品。人们购买米大多采用直接称量的方法,市面上也有许多仪器采用光电传感器等方式用于生产

1 简介

大米是人类的主食之一,是稻谷经清理、砻谷、碾米、成品整理等工序后制成的成品。人们购买米大多采用直接称量的方法,市面上也有许多仪器采用光电传感器等方式用于生产加工时米粒的计数。然而这样的方法都比较依赖于设备,不方便人们日常的使用。运用计算机图像处理技术,可以在缺少专用设备的情况下,快速简单地完成对米粒或其他颗粒的计数。

​2 部分代码

function varargout = riceNumber(varargin)
% RICENUMBER M-file for riceNumber.fig
% RICENUMBER, by itself, creates a new RICENUMBER or raises the existing
% singleton*.
%
% H = RICENUMBER returns the handle to a new RICENUMBER or the handle to
% the existing singleton*.
%
% RICENUMBER('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in RICENUMBER.M with the given input arguments.
%
% RICENUMBER('Property','Value',...) creates a new RICENUMBER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before riceNumber_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% top. All inputs are passed to riceNumber_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help riceNumber
% Last Modified by GUIDE v2.5 31-Mar-2022 10:40:23
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @riceNumber_OpeningFcn, ...
'gui_OutputFcn', @riceNumber_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before riceNumber is made visible.
function riceNumber_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to riceNumber (see VARARGIN)
% Choose default command line output for riceNumber
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
end
RiceNumber = flag;
R=100;
set(handles.text1,'string',sprintf('%3.0f',RiceNumber ));
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit1_Callback(hObject, eventdata, handles)
str=get(hObject,'string');
handles.b=str;
guidata(hObject,handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_4_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_5_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_6_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_7_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_9_Callback(hObject, eventdata, handles)
msgbox({'1、点击读取图像以选择相应像后,点击计算数值即可。'; ...
'2、点击菜单栏中的文件->提取图像,再点击文件->计算数值即可。'},'操作提示');
% hObject handle to Untitled_9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_10_Callback(hObject, eventdata, handles)
msgbox({'大米粒数计算'}, '关于');
% hObject handle to Untitled_10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_11_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function Untitled_12_Callback(hObject, eventdata, handles)
close(gcf)
% hObject handle to Untitled_12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

3 仿真结果

【大米粒计数】基于计算机视觉实现大米粒颗粒识别含Matlab源码_菜单栏

4 参考文献


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

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

【大米粒计数】基于计算机视觉实现大米粒颗粒识别含Matlab源码_ide_02


网友评论