【问题标题】:Inserting a link into an image in matlab?在matlab中将链接插入图像中?
【发布时间】:2011-10-19 09:57:41
【问题描述】:

我想在 matlab 中的图像中放置一个文档链接。我有一个特定的地区要放置链接。例如,我希望图像中的位置 x = 40, y = 120 与文档的地址有链接。类似于下面的内容,我知道这不是正确的 matlab 代码。

text(40,120, '<a href="C:\Documents and Settings\Sentinelle\Desktop\LCModel\sl5_knt1\sl5_11-6.pdf"; ">Click here for plot documentation</a>')

这有可能吗?我希望能够使用 imshow() 或 imtool() 并能够单击图像区域并查看文档。

【问题讨论】:

    标签: image matlab hyperlink


    【解决方案1】:

    您可以使用OPEN函数设置'ButtonDownFcn'文本属性来打开给定的文档:

    filePath = 'C:\Documents and Settings\Sentinelle\Desktop\LCModel\sl5_knt1\sl5_11-6.pdf';
    text(40,120,'Click here for plot documentation',...
         'ButtonDownFcn',['open(''' filePath ''');']);
    

    【讨论】:

    • 我喜欢这个主意,但我收到了这个错误???使用 ==> 时出错 open Too many input arguments。 ???评估文本时出错 ButtonDownFcn
    • @Ben:哦,我明白了。您的文件路径中有空格。我将对此进行编辑。
    【解决方案2】:

    根据类似的discussion,您可以创建一个UICONTROL pushbutton,其优点是它接受HTML输入字符串。然后使用FINDJOBJ,我们可以伪造一个可点击的超链接的样子:

    fName = 'C:\path\to\file.pdf';
    str = '<html><a href="">Click here for plot documentation</a></html>';
    
    figure('Resize','off', 'MenuBar','none')
    imshow('coins.png')
    hButton = uicontrol('Style','pushbutton', 'Position',[320 50 170 20], ...
        'String',str, 'Callback',@(o,e)open(fName));
    
    jButton = findjobj(hButton);
    jButton.setCursor( java.awt.Cursor(java.awt.Cursor.HAND_CURSOR) );
    jButton.setContentAreaFilled(0); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 2011-12-08
      • 2018-06-20
      • 2019-12-14
      • 2014-11-14
      • 1970-01-01
      • 2014-04-10
      相关资源
      最近更新 更多