function varargout = xiangguan(varargin)
% XIANGGUAN M-file for xiangguan.fig
% XIANGGUAN, by itself, creates a new XIANGGUAN or raises the existing
% singleton*.
%
% H = XIANGGUAN returns the handle to a new XIANGGUAN or the handle to
% the existing singleton*.
%
% XIANGGUAN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in XIANGGUAN.M with the given input arguments.
%
% XIANGGUAN('Property','Value',...) creates a new XIANGGUAN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before xiangguan_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to xiangguan_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 xiangguan
% Last Modified by GUIDE v2.5 20-Apr-2014 10:31:06
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @xiangguan_OpeningFcn, ...
'gui_OutputFcn', @xiangguan_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 xiangguan is made visible.
function xiangguan_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 xiangguan (see VARARGIN)
% Choose default command line output for xiangguan
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes xiangguan wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = xiangguan_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 first_picture.
function first_picture_Callback(hObject, eventdata, handles)
% hObject handle to first_picture (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
subplot(3,3,2)
[filename,pathname]=uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'open'); %打开路径下要检索的图像
if isequal([filename,pathname],[0,0])
return
else
%读取图片
pic = fullfile(pathname,filename);
global onion;
onion = imread(pic);
imshow(onion);
end
% --- Executes on button press in second_picture.
function second_picture_Callback(hObject, eventdata, handles)
% hObject handle to second_picture (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
subplot(3,3,3)
[filename,pathname]=uigetfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
'*.*','All Files' },'open'); %打开路径下要检索的图像
if isequal([filename,pathname],[0,0])
return
else
%读取图片
pict = fullfile(pathname,filename);
global peppers;
peppers = imread(pict);
imshow(peppers);
end
% --- Executes on button press in correlation.
function correlation_Callback(hObject, eventdata, handles)
% hObject handle to correlation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
subplot(3,3,5)
global onion;
global peppers;
% non-interactively
rect_onion = [111 33 65 58];
rect_peppers = [163 47 143 151];
sub_onion = imcrop(onion,rect_onion);
sub_peppers = imcrop(peppers,rect_peppers);
c = normxcorr2(sub_onion(:,:,1),sub_peppers(:,:,1));
surf(c), shading flat
% --- Executes on button press in overlay.
function overlay_Callback(hObject, eventdata, handles)
% hObject handle to overlay (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
subplot(3,3,6)
global onion;
global peppers;
% non-interactively
rect_onion = [111 33 65 58];
rect_peppers = [163 47 143 151];
sub_onion = imcrop(onion,rect_onion);
sub_peppers = imcrop(peppers,rect_peppers);
c = normxcorr2(sub_onion(:,:,1),sub_peppers(:,:,1));
% offset found by correlation
[max_c, imax] = max(abs(c(:)));
[ypeak, xpeak] = ind2sub(size(c),imax(1));
corr_offset = [(xpeak-size(sub_onion,2))
(ypeak-size(sub_onion,1))];
% relative offset of position of subimages
rect_offset = [(rect_peppers(1)-rect_onion(1))
(rect_peppers(2)-rect_onion(2))];
% total offset
offset = corr_offset + rect_offset;
xoffset = offset(1);
yoffset = offset(2);
xbegin = round(xoffset+1);
xend = round(xoffset+ size(onion,2));
ybegin = round(yoffset+1);
yend = round(yoffset+size(onion,1));
% extract region from peppers and compare to onion
extracted_onion = peppers(ybegin:yend,xbegin:xend,:);
if isequal(onion,extracted_onion)
disp('onion.png was extracted from peppers.png')
end
recovered_onion = uint8(zeros(size(peppers)));
recovered_onion(ybegin:yend,xbegin:xend,:) = onion;
imshow(recovered_onion)
% --- Executes on button press in transparent.
function transparent_Callback(hObject, eventdata, handles)
% hObject handle to transparent (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
subplot(3,3,8)
global onion;
global peppers;
% non-interactively
rect_onion = [111 33 65 58];
rect_peppers = [163 47 143 151];
sub_onion = imcrop(onion,rect_onion);
sub_peppers = imcrop(peppers,rect_peppers);
c = normxcorr2(sub_onion(:,:,1),sub_peppers(:,:,1));
% offset found by correlation
[max_c, imax] = max(abs(c(:)));
[ypeak, xpeak] = ind2sub(size(c),imax(1));
corr_offset = [(xpeak-size(sub_onion,2))
(ypeak-size(sub_onion,1))];
% relative offset of position of subimages
rect_offset = [(rect_peppers(1)-rect_onion(1))
(rect_peppers(2)-rect_onion(2))];
% total offset
offset = corr_offset + rect_offset;
xoffset = offset(1);
yoffset = offset(2);
xbegin = round(xoffset+1);
xend = round(xoffset+ size(onion,2));
ybegin = round(yoffset+1);
yend = round(yoffset+size(onion,1));
% extract region from peppers and compare to onion
extracted_onion = peppers(ybegin:yend,xbegin:xend,:);
if isequal(onion,extracted_onion)
disp('onion.png was extracted from peppers.png')
end
recovered_onion = uint8(zeros(size(peppers)));
recovered_onion(ybegin:yend,xbegin:xend,:) = onion;
[m,n,p] = size(peppers);
mask = ones(m,n);
i = find(recovered_onion(:,:,1)==0);
mask(i) = .2; % try experimenting with different levels of
% transparency
% overlay images with transparency
imshow(peppers(:,:,1)) % show only red plane of peppers
hold on
h = imshow(recovered_onion); % overlay recovered_onion
set(h,'
Matlab领域
- 粉丝: 3w+
- 资源: 3674
最新资源
- A股本轮牛市新高度预测:数据统计揭示最高点位,散户如何布局牛市?.mp4
- springboot项目中小型制造企业质量管理系统.zip
- springboot项目助农管理系统.zip
- springboot项目助农产品采购平台设计与实现.zip
- springboot项目足球社区管理系统.zip
- springboot项目足球俱乐部管理系统.zip
- 抖音无人直播,会说话的汤姆猫弹幕互动小游戏,两场直播6000+.mp4
- COMSOL裂缝地层的THM耦合,离散裂缝模型,随机复杂裂缝,适合地热能研究
- dma接口数据手册PDF
- 短视频抖店蓝海课程:从基础功能到变现方式,轻松打造爆款短视频.mp4
- 短视频制作与运营全攻略:拍摄剪辑全流程,带你0到1做流量变现.mp4
- 短视频文案创作教程:从钉子思维到实操结构整改,轻松提升文案质量.mp4
- Comsol砷化镓和频SFG
- 快手&俄罗斯 数字人带货:流量获取与选品策略 文案制作与账号运营指南.mp4
- 基于simulink的8阶lms自适应滤波器模型,纯手搭 非软件自带lms库,图示为降噪效果 第一行为加噪信号; 第二行为滤波器输出; 第三行为降噪结果 可广泛应用于数字域噪声抵消的原型验证,具有
- JavaScript逆向(一)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈