当前位置:网站首页>MATLAB GUI---PicZoom动画演示
MATLAB GUI---PicZoom动画演示
2022-04-21 10:56:00 【小宇2022】

function varargout = piczoom(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @piczoom_OpeningFcn, ...
'gui_OutputFcn', @piczoom_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
function piczoom_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
%m为图片的纵向像素数,n为图片的横向像素数,mapData为修正后的图像数据
global m n mapData
%读取图片到主坐标轴axes1
axes(handles.axes1);
cData = imread('20220421T073618_3.bmp');
hImage = image(cData);
axis off;
%设置当前坐标轴为右上角的小坐标轴axes2
axes(handles.axes2);
%初始化全局变量m和n
m = size(cData, 1);
n = size(cData, 2);
%扩展图片数据,使得鼠标在图片边缘附近时,不至于出错
mapData = 255 * ones(m+40, n+40, size(cData, 3), 'uint8');
mapData(21:m+20, 21:n+20, :) = cData;
%将图片数据存到handles结构体中
handles.hImage = hImage;
%更新handles
guidata(hObject, handles);
function varargout = piczoom_OutputFcn(hObject, eventdata, handles)
varargout{
1} = handles.output;
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
global m n mapData
%获取鼠标当前所在的点
pos = get(handles.axes1, 'CurrentPoint');
posX = pos(1, 1);
posY = pos(1, 2);
%若鼠标在坐标轴区域内,更新小坐标轴axes2
if((posX >= 1) && (posX <= n) &&...
(posY >= 1) && (posY <= m))
x = floor(posY) + 20;
y = floor(posX) + 20;
cData = mapData(x-20: x+20, y-20:y+20, :);
axes(handles.axes2);
image(cData);
axis off;
end
版权声明
本文为[小宇2022]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_38127487/article/details/124312246
边栏推荐
- [pytorch] 1-to-many IOU calculation skills
- L1-045 cosmic invincible greeting (5 points)
- C语言 字符串
- 8-channel can FD, more powerful data recorder gl3400
- Use of laravel redis
- 依然AC自动机
- [wcn685x] how to determine which bdwlan file is called by WiFi driver?
- Showcase时手机不够怎么办? 云真机平台atxserver2
- Postman setting environment variables is simple and practical
- Pytoch learning notes (1) check the creation of torch, CUDA and tensor
猜你喜欢

Motor control - speed loop design

TypeError: The view function did not return a valid response. The function either returned None 的解决

P4 Tutorials---- source routing

pip install的时候出现问题,无法连接...(pip配置镜像源)

桶排序 ← C语言实现

Bucket sorting ← C language implementation

力扣(LeetCode)110. 平衡二叉树(2022.04.20)

Enter the welcome interface when idea and pycharm are started

Why programming is so difficult: starting from the deduction of stored value card

【生活中的逻辑谬误】对人不对事和两难陷阱
随机推荐
Println input and rewriting of toString method
A collection of econometric models and empirical Stata codes, with top publication examples
Problems needing attention when using scanf function in C language
ConvBERT: Improving BERT with Span-based Dynamic Convolution论文的阅读笔记
Teach you by hand: rolling bearing fault diagnosis based on deep learning
递归函数 C语言 题型
力扣(LeetCode)110. 平衡二叉树(2022.04.20)
00000000000000000000000
hyperf 执行sql语句,参数会有两个单引号
Applet lifecycle
(坐标型动态规划)lintcode中等248 · 统计比给定整数小的数的个数
犀牛软件插件-rhino插件-visual studio-创建你的第一个插件
后缀数组应用
GO函数的使用
Théorie moderne du risque actuariel 07: mesure du risque
torch. autograd. Function customization
泛型note
拓扑排序&关键路径&数位dp
暴力破解美团最新JVM面试题
【leetcode】647.回文子串