【水果識(shí)別】基于形態(tài)學(xué)實(shí)現(xiàn)水果大小識(shí)別含Matlab源碼
1 簡介
在現(xiàn)實(shí)生活中成人識(shí)別水果是十分簡易的但對(duì)于幼兒來說在沒有實(shí)物之前是無法識(shí)別水果的,因此本文設(shè)計(jì)了一個(gè)簡易水果識(shí)別系統(tǒng)為幼兒在電子設(shè)備上識(shí)別水果提供可能.本文通過matlab GUI設(shè)計(jì)了一個(gè)水果識(shí)別系統(tǒng)界面并通過對(duì)水果圖像進(jìn)行二值化處理,邊緣處理最后實(shí)現(xiàn)了水果分類,結(jié)果由設(shè)計(jì)的GUI界面所示.我們通過算法成功的識(shí)別了香蕉,蘋果,楊桃,檸檬和獼猴桃.我們可以通過該算法實(shí)現(xiàn)的水果識(shí)別并為教導(dǎo)幼兒實(shí)現(xiàn)電子識(shí)別水果提供方便.
2 部分代碼
function varargout = fruit_identify(varargin)
% FRUIT_IDENTIFY M-file for fruit_identify.fig
% ? ? ?FRUIT_IDENTIFY, by itself, creates a new FRUIT_IDENTIFY or raises the existing
% ? ? ?singleton*.
%
% ? ? ?H = FRUIT_IDENTIFY returns the handle to a new FRUIT_IDENTIFY or the handle to
% ? ? ?the existing singleton*.
%
% ? ? ?FRUIT_IDENTIFY('CALLBACK',hObject,eventData,handles,...) calls the local
% ? ? ?function named CALLBACK in FRUIT_IDENTIFY.M with the given input arguments.
%
% ? ? ?FRUIT_IDENTIFY('Property','Value',...) creates a new FRUIT_IDENTIFY or raises the
% ? ? ?existing singleton*. ?Starting from the left, property value pairs are
% ? ? ?applied to the GUI before fruit_identify_OpeningFcn gets called. ?An
% ? ? ?unrecognized property name or invalid value makes property application
% ? ? ?stop. ?All inputs are passed to fruit_identify_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 fruit_identify
% Last Modified by GUIDE v2.5 22-May-2021 10:27:49
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', ? ? ? mfilename, ...
? ? ? ? ? ? ? ? ? 'gui_Singleton', ?gui_Singleton, ...
? ? ? ? ? ? ? ? ? 'gui_OpeningFcn', @fruit_identify_OpeningFcn, ...
? ? ? ? ? ? ? ? ? 'gui_OutputFcn', ?@fruit_identify_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 fruit_identify is made visible.
function fruit_identify_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 fruit_identify (see VARARGIN)
% Choose default command line output for fruit_identify
handles.output = hObject;
im=imread('pic.jpg');
axes(handles.axes1)
imshow(im)
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes fruit_identify wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = fruit_identify_OutputFcn(hObject, eventdata, handles)
% varargout ?cell array for returning output args (see VARARGOUT);
% hObject ? ?handle to figure
end
%變換生成最終的結(jié)果圖像,圖像中顯示的結(jié)果即對(duì)應(yīng)分類器中指定的類別
fruit_matrix = hsv2rgb(fruit_HSV); ? %轉(zhuǎn)換為RGB彩圖,彩圖中已經(jīng)濾去了其余物體,只剩下當(dāng)前目標(biāo)物
axes(handles.axes3);
imshow(fruit_matrix);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 仿真結(jié)果


4 參考文獻(xiàn)
[1]楊霈. 基于matlab GUI的水果識(shí)別系統(tǒng)[J]. 電子制作, 2021(12):2.
博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測、信號(hào)處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無人機(jī)等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡(luò)文獻(xiàn),若有侵權(quán)聯(lián)系博主刪除。
