• 网志分类
  • » 查看所有日志
    » 个人相关
    » 网友问题解答
    » 模拟一些现象的M程序
    » 用MATLAB写的一些游戏
    » 实现特殊功能的M程序
    » 元胞自动机的M程序
    » 分形、混沌的M程序
    » 日常知识积累
    » 程序调试
    » TeX相关资料
    » 用户界面设计GUI
    » 特殊图形
    » MATLAB小知识
    » 消息
    » 被遗忘的角落
  • 站内搜索
  • 友情链接
  • » 我的歪酷 非非共享界
    » My new blog
    » 博客2站:163博客
    » 分形软件
    » 分形频道
    » 紫丁香社区
    » 研学论坛
    » 数字图像网
    » 仿真论坛MATLAB版
    » HIT振动中心网站
    » 分形艺术
    » comp.soft-sys.matlab
    » matalks.com
    » 动力学与控制 MATLAB
    » 研学之路-混沌序列建模
    » 山城棒棒儿的MATLAB世界
    » 总统博客
    » 亚丁小屋
    » 一米阳光
    » 行运流水
    » 王丙的日记
    » 蓝色星空
    » 小飞的blog
    » 控制★编程★生活★其他
    » 纳沙
    » 儿子的博客

    订阅 RSS

    歪酷博客

    0438925

    « 上一篇: 定义matlab中的符号常量 下一篇: 画正N边形 »
    萝卜 @ 2005-05-10 12:30

    发信人: Genial (山城棒棒儿军), 信区: MathTools
    标  题: 动态显示鼠标的坐标值和图像像素值 zz
    发信站: 饮水思源 (2003年12月19日00:19:10 星期五), 站内信件

    对于动态显示鼠标的坐标值和像素值,在其他语言如vc,vb中都比较方便,有直接的着方
    面的函数,那么在matlab图像处理里面又如何实现呢?
    具体的实现方法很多,但归结起来就是获取坐标轴的current point 属性值,我这里给
    出的一个函数是从mathworks 获取柄稍作修改后的结果,相信对做图像处理的朋友有一
    定的作用。另一个就是自带的pixval函数。谁有不同的实现方法,请多多共享啊!

    function dynpoint(arg,h)
    % Show the coordinates of a plot dynamically
    %
    % To start use:
    % dynpoint(h)
    % where h is a handle to a figure, axes or e.g. line.
    %
    % To delete use:
    % dynpoint('delete',h)
    % where h is a handle to a figure, axes or e.g. line.
    % (you may also use: dynpoint delete)
    %
    % There can only be one dynamic plotter in a figure at a time.
    %
    % Example:
    % subplot(211), hline = plot(sin(1:10))
    % subplot(212), plot(sin(1:100))
    % dynpoint(hline)

    % 2002,6.29

    if ~exist('arg','var')
       arg = gcf;
    end

    if ~isstr(arg)
     handle = arg;
     arg = 'init';
    end

    switch arg
    case 'init'
       if ~ishandle(handle)
           error('h is not a handle')
       end

       [h,ax] = h2hax(handle);

       % delete old dynamic text object
       ht = findobj(h,'tag',[mfilename '_text']);
       if any(ht)
           delete(ht)
       end

       % text window at the bottom left corner
       % text in centred
       uicontrol(h,...
           'style','text',...
           'pos',[2 2 200 15],...
           'tag',[mfilename '_text'],...
           'userdata',ax(1))

       % do the dynamic thing...
       set(h,'windowbuttonmotionfcn',[mfilename ' move'])

    case 'move'
       ht = findobj(gcbf,'tag',[mfilename '_text']);
       ax = overobj('axes');
       if ~any(ax)
           ax = get(ht,'userdata');
       end
       p = get(ax,'currentpoint');
       set(ht,'string',sprintf('(%g, %g)', p(1), p(3)));

    case 'delete'
       if ~exist('h','var')
           h = gcf;
       end
        [h,ax] = h2hax(h);
       set(h,'windowbuttonmotionfcn','')

       ht = findobj(h,'tag',[mfilename '_text']);
       delete(ht)

    end

    % ----------
    function [h,ax]=h2hax(handle)

    typ = get(handle,'type');
    if strcmp(typ,'figure')
       h = handle;
       ax = findobj(h,'type','axes');
    elseif strcmp(typ, 'axes')
       h = get(handle,'parent');
       ax = handle;
    elseif strcmp( get(get(handle,'parent'), 'type'), 'axes' )
       ax = get(handle,'parent');
       h = get(ax,'parent');
    end

    最新评论


    2008-03-30 02:25 匿名 219.225.*.*

    这个我找了很久了
    你的很好啊
    非常感谢


    评论 / 个人网页 / 扔小纸条
    * 昵称

    已经注册过? 请登录

    新用户请先注册 以便能显示头像及追踪评论回复

    Email
    网址
    * 评论
    表情
     


     

    分类小组论坛
    杂谈 , 娱乐、八卦 , 文学、艺术 , 体育 , 旅游、同城 , 象牙塔 , 情感 , 时尚、生活 , 星座 , 科技

    请注意遵守中华人民共和国法律法规, 如威胁到本站生存, 将依法向有关部门报告, 同时本站的相关记录可能成为对您不利的证据.

    相关法律法规
    全国人大常委会关于维护互联网安全的决定
    中华人民共和国计算机信息系统安全保护条例
    中华人民共和国计算机信息网络国际联网管理暂行规定
    计算机信息网络国际联网安全保护管理办法
    计算机信息系统国际联网保密管理规定