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

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码

来源:互联网 收集:自由互联 发布时间:2022-06-15
1 简介 ​ ​ 正在上传…重新上传取消 2 部分代码 function varargout = mygui(varargin) % Begin initialization code - DO NOT EDIT gui_Singleton = 1; global im; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gu


1 简介

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码_2d

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码_选择图片_02

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码_选择图片_03

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码_上传_04

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码_2d_05正在上传…重新上传取消

2 部分代码

function varargout = mygui(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
global im;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mygui_OpeningFcn, ...
'gui_OutputFcn', @mygui_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 mygui is made visible.
function mygui_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 mygui (see VARARGIN)
% Choose default command line output for mygui
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes mygui wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = mygui_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in open_pushbutton.
function open_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to open_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im;
[filename,pathname]=...
uigetfile({'*.*';'*.bmp';'*.tif';'*.png';'*.gif';'*.jpg'},'select picture'); %选择图片路径
str = [pathname filename]; %合成路径+文件名
im = imread(str); %读取图片
axes(handles.axes1); %使用第一个axes
imshow(im); %显示图片
title('原图像');
% --- Executes on button press in blpf_pushbutton.
function blpf_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to blpf_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im;
button_state = get(hObject,'Value');
if button_state == get(hObject,'Max')
I0 = im;
% I0 = imread('beauty.jpg');
% subplot(2,2,1),imshow(I0);title('原图');
str={'半径D0大小:','阶数n:'}; %输入相关参数:高斯模板大小、方差、二值化阈值
sData=InputDlg(str,'输入参数',1);
if ~isempty(sData)
d0=str2double(sData(1));%模板大小
n=str2double(sData(2));%次数
end
I1 = imnoise(I0,'gaussian'); %对原图像加噪声
% subplot(2,2,2),imshow(I1);title('加入噪声后图像')
%将灰度图像的二维不连续Fourier 变换的零频率成分移到频谱的中心
s=fftshift(fft2(I1));
[M,N]=size(s); %分别返回s的行数到M中,列数到N中
n1=floor(M/2); %对M/2进行取整

3 仿真结果

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码_上传_06

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码_上传_07

4 参考文献

[1]洪华庆. 基于计算机视觉的米粒质量检测系统[D]. 浙江工商大学.

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

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

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码_选择图片_08

【图像检测】基于计算机视觉实现米粒个数检测含Matlab源码_2d_09

网友评论