Android水果超市的登录界面,【水果识别】自助水果超市matlab源码含 GUI

一、简介

基于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 %定义一个全局变量im

[filename,pathname,filterindex]=uigetfile({'*.jpg';'*.png'},'选择图片')

str=[pathname filename]; %合成路径+文件名

image=imread(str); %读取图片

axes(handles.axes1); %使用第一个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);

%%%%%以上是图像二值化 上面制作二值化图像

%下面计算圆度

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

三、运行结果

121ac00cc1ce484589bd2d72350c0450.jpg

四、备注

完整代码或者代写添加QQ1575304183

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值