【圖像檢測(cè)】基于計(jì)算機(jī)視覺實(shí)現(xiàn)米粒個(gè)數(shù)檢測(cè)含Matlab源碼
1 簡(jiǎn)介



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); ?%使用第一個(gè)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大?。?#39;,'階數(shù)n:'}; ? ? ? ? ? ? ? ? ? ? ? ? ? ? %輸入相關(guān)參數(shù):高斯模板大小、方差、二值化閾值
? ? ? ?sData=InputDlg(str,'輸入?yún)?shù)',1);
? ? ? ?if ~isempty(sData)
? ? ? ? ? ?d0=str2double(sData(1));%模板大小
? ? ? ? ? ?n=str2double(sData(2));%次數(shù)
? ? ? ?end ? ?
? ? ? ?I1 = imnoise(I0,'gaussian'); ? ? ? ? %對(duì)原圖像加噪聲
% ? ? ? ? subplot(2,2,2),imshow(I1);title('加入噪聲后圖像')
? ? ? ? %將灰度圖像的二維不連續(xù)Fourier 變換的零頻率成分移到頻譜的中心
? ? ? ?s=fftshift(fft2(I1));
? ? ? ?[M,N]=size(s); ? ? ? ? ? ? ? ? ? ? ?%分別返回s的行數(shù)到M中,列數(shù)到N中
? ? ? ?n1=floor(M/2); ? ? ? ? ? ? ? ? ? ? ? %對(duì)M/2進(jìn)行取整
3 仿真結(jié)果

4 參考文獻(xiàn)
[1]洪華慶. 基于計(jì)算機(jī)視覺的米粒質(zhì)量檢測(cè)系統(tǒng)[D]. 浙江工商大學(xué).
博主簡(jiǎn)介:擅長(zhǎng)智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測(cè)、信號(hào)處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無人機(jī)等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡(luò)文獻(xiàn),若有侵權(quán)聯(lián)系博主刪除。
