⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcmgui.m

📁 function varargout = lcmgui(varargin) % LCMGUI M-file for lcmgui.fig % LCMGUI, by itself, creates
💻 M
字号:
function varargout = lcmgui(varargin)
% LCMGUI M-file for lcmgui.fig
%      LCMGUI, by itself, creates a new LCMGUI or raises the existing
%      singleton*.
%
%      H = LCMGUI returns the handle to a new LCMGUI or the handle to
%      the existing singleton*.
%
%      LCMGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in LCMGUI.M with the given input arguments.
%
%      LCMGUI('Property','Value',...) creates a new LCMGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before lcmgui_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to lcmgui_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 lcmgui

% Last Modified by GUIDE v2.5 19-Dec-2007 22:59:00

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @lcmgui_OpeningFcn, ...
                   'gui_OutputFcn',  @lcmgui_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 lcmgui is made visible.
function lcmgui_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 lcmgui (see VARARGIN)

% Choose default command line output for lcmgui
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes lcmgui wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = lcmgui_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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% 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)
axes(handles.axes1);
cla;

popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
    case 1
        imshow('IMG_3292.jpg');
    case 2
        imshow('黄山01.jpg');
    case 3
        %从图中分离出人物
a=imread('IMG_3292.jpg');
aa=a(:,:,3);  %把第三维拿出来即得灰度图象
b=imresize(aa,0.1);  %图像的0.1倍
c2=im2bw(b,170/255);  %灰度转二值,黑0白1
c2=~c2;

%把人物附到另一个图像上
for i=1:170;
    for j=1:227;
        if c2(i,j)==0;
            b(i,j)=0;%人轮廓以外区域变黑——选出人物
        end
    end
end
m=imread('黄山01.jpg');
mm=m(:,:,3);
for i=1:170;
    for j=1:227;
        if b(i,j)~=0;%人的轮廓图
            mm(80+i,340+j)=0;%先是要覆盖区域变黑,防止二图灰度叠加过亮
            mm(80+i,340+j)=mm(80+i,340+j)+b(i,j);%二图叠加
        end
    end
end
imshow(mm)

end

% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu 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
set(hObject, 'String', {'人物', '背景', '合成'});

% --------------------------------------------------------------------
function Untitled_3_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
axes(handles.axes1)
[filename,pathname]=uigetfile('*.bmp;*.jpg;*.tif');
f=fullfile(pathname,filename);
X=imread(f);
handles.figg=X;
guidata(hObject, handles);
imshow(X)


% --------------------------------------------------------------------
function Untitled_4_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close

% --------------------------------------------------------------------
function Untitled_5_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -