最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

【水果識(shí)別】自助水果超市matlab源碼含 GUI

2021-08-26 00:06 作者:Matlab工程師  | 我要投稿

一、簡(jiǎn)介

基于matlab自助水果超市

二、源代碼

function varargout = rmbbb(varargin) % RMBBB MATLAB code for rmbbb.fig % ? ? ?RMBBB, by itself, creates a new RMBBB or raises the existing % ? ? ?singleton*. % % ? ? ?H = RMBBB returns the handle to a new RMBBB or the handle to % ? ? ?the existing singleton*. % % ? ? ?RMBBB('CALLBACK',hObject,eventData,handles,...) calls the local % ? ? ?function named CALLBACK in RMBBB.M with the given input arguments. % % ? ? ?RMBBB('Property','Value',...) creates a new RMBBB or raises the % ? ? ?existing singleton*. ?Starting from the left, property value pairs are % ? ? ?applied to the GUI before rmbbb_OpeningFcn gets called. ?An % ? ? ?unrecognized property name or invalid value makes property application % ? ? ?stop. ?All inputs are passed to rmbbb_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 rmbbb % Last Modified by GUIDE v2.5 11-Oct-2017 22:05:01 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', ? ? ? mfilename, ... ? ? ? ? ? ? ? ? ? 'gui_Singleton', ?gui_Singleton, ... ? ? ? ? ? ? ? ? ? 'gui_OpeningFcn', @rmbbb_OpeningFcn, ... ? ? ? ? ? ? ? ? ? 'gui_OutputFcn', ?@rmbbb_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 rmbbb is made visible. function rmbbb_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 rmbbb (see VARARGIN) % Choose default command line output for rmbbb handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes rmbbb wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = rmbbb_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; function pushbutton1_Callback(hObject, eventdata, handles) % --- Executes on button press in pushbutton1. % hObject ? ?handle to pushbutton1 (see GCBO) % eventdata ?reserved - to be defined in a future version of MATLAB % handles ? ?structure with handles and user data (see GUIDATA) global image ?%定義一個(gè)全局變量im [filename,pathname,filterindex]=uigetfile({'*.jpg';'*.png'},'選擇圖片') str=[pathname filename]; %合成路徑+文件名 image=imread(str); ?%讀取圖片 axes(handles.axes1); ?%使用第一個(gè)axes imshow(image); ?%顯示圖片 RGB = image; I = rgb2gray(RGB); threshold = graythresh(I); bw = im2bw(I,threshold); ? % remove all object containing fewer than 30 pixels bw = bwareaopen(bw,30); % fill a gap in the pen's cap se = strel('disk',2); bw = imclose(bw,se); ? % fill any holes, so that regionprops can be used to estimate % the area enclosed by each of the boundaries bw = imfill(bw,'holes'); ? ed=edge(bw); %%%%%以上是圖像二值化 上面制作二值化圖像 %下面計(jì)算圓度 L = bwlabel(bw); L1 = bwlabel(ed); Ar=zeros(1,max(L(:))); Pr=zeros(1,max(L1(:))); for i=1:max(L(:)) Ar(i)=sum(bw(L==i)); [y,x]=find(L==i); x0=min(x(:)); x1=max(x(:)); y0=min(y(:)); y1=max(y(:)); Pr(i)=Ar(i)/((y1-y0)*(x1-x0)); end if max(Pr) >0.81 ? ?note=1 else ? ?note=0 end if note==1 imager=image(:,:,1); imageg=image(:,:,2); r=sum(sum(imager)); g=sum(sum(imageg)); bizhi=r/g; if bizhi>1.15 ? ?money=100 elseif bizhi<0.93 ? ?money=50 elseif (bizhi>1.08)&(bizhi<1.15) ? ?money=20 elseif (bizhi>1.0)&(bizhi<1.03) ? ?money=10 elseif (bizhi>1.03)&(bizhi<1.08) ? ?money=5 elseif (bizhi>0.93)&(bizhi<1.0) ? ?money=1 end end if note==0 ? ?total= bwarea(bw) if total>12000 ? ?money=1 elseif (total>10000)&(total<12000) ? ?money=0.5 elseif (total>8700)&(total<10000) ? ?money=0.1 else ? ?money=0 end end global allmoney; set(handles.edit1,'string',money); allmoney=allmoney+money; set(handles.edit8,'string',allmoney); function edit1_Callback(hObject, eventdata, 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 allmoney=0; function edit3_Callback(hObject, eventdata, handles) % hObject ? ?handle to edit3 (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 edit3 as text % ? ? ? ?str2double(get(hObject,'String')) returns contents of edit3 as a double % --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject ? ?handle to edit3 (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

三、運(yùn)行結(jié)果

在這里插入圖片描述

?

?


【水果識(shí)別】自助水果超市matlab源碼含 GUI的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
瓮安县| 胶州市| 莱阳市| 于都县| 白水县| 灵川县| 阳朔县| 松滋市| 北票市| 清流县| 漯河市| 保康县| 桃江县| 长顺县| 阿拉善盟| 崇州市| 昭平县| 黄石市| 门头沟区| 博客| 宣化县| 漳州市| 诸城市| 南通市| 定结县| 隆子县| 仁寿县| 宁南县| 长海县| 普兰县| 宾川县| 安泽县| 景德镇市| 揭阳市| 长子县| 芦溪县| 建水县| 林甸县| 鸡东县| 安远县| 姜堰市|