2009-10-22 37 views
-1

我在previous question中询问了如何在MATLAB中重现an image。现在,我想通过删除单词“数学”并用MathWorks logo替换它来修改该图像。如何将MathWorks标志添加到MATLAB中的图像中?

我很难弄清楚如何将徽标添加到图形并调整其位置。

这是我一直在试图使用的徽标添加到图中的代码:

L = 40*membrane(1,25); 

logoFig = figure('Color',[1 1 1]); 
logoax = axes('CameraPosition', [80.5 50 42.5],... 
    'CameraTarget',[26 26 10], ... 
    'CameraUpVector',[0 0 1], ... 
    'CameraViewAngle',9.5, ... 
    'DataAspectRatio', [1 1 .9],... 
    'Position',[0 0 1 1], ... 
    'Visible','off', ... 
    'XLim',[1 51], ... 
    'YLim',[1 51], ... 
    'ZLim',[-13 40], ... 
    'parent',logoFig); 
s = surface(L, ... 
    'EdgeColor','none', ... 
    'FaceColor',[0.9 0.2 0.2], ... 
    'FaceLighting','phong', ... 
    'AmbientStrength',0.3, ... 
    'DiffuseStrength',0.6, ... 
    'Clipping','off',... 
    'BackFaceLighting','lit', ... 
    'SpecularStrength',1.1, ... 
    'SpecularColorReflectance',1, ... 
    'SpecularExponent',7, ... 
    'Tag','TheMathWorksLogo', ... 
    'parent',logoax); 
l1 = light('Position',[40 100 20], ... 
    'Style','local', ... 
    'Color',[0 0.8 0.8], ... 
    'parent',logoax); 
l2 = light('Position',[.5 -1 .4], ... 
    'Color',[0.8 0.8 0], ... 
    'parent',logoax); 

%http://www.mathworks.com/products/matlab/demos.html?file=/products/demos/shipping/matlab/logo.html 
+5

@izzat:我不愿意帮你了,因为很可能你只是要删除这个问题在你得到你的答案之后,就像你以前做过的那样。 Stack Overflow的要点不仅仅是为了回答*你的问题,而是为了创建* others的编程帮助库来使用。如果你要自私而不让其他人阅读,为什么我应该花大力气发布一个答案? – gnovice 2009-10-22 17:48:22

+0

我为了设置'位置'我必须'看''把我想放的所需数字放在哪里。我怎么能'看到'? – izzat 2009-10-22 17:58:26

+0

我不会自私 – izzat 2009-10-22 19:08:53

回答

4

你似乎遇到了很多麻烦搞清楚了这一点。这是我想你想生成图像:

alt text

首先,我开始与功能heartI_Heart_Math,我张贴在my answer to your other question(使用arrow.mmyaa.mThe MathWorks File Exchange)。我删除了I_Heart_Math中与绘制单词“数学”相关的所有代码,并减小了数字窗口的大小。

接下来,我必须生成并绘制MATLAB L形膜徽标。在MATLAB中,你可以输入logo,它会打开一个黑色背景上显示徽标的新图。您可以通过在MATLAB中输入type logo来查看生成该图的代码,也可以查看this MathWorks demo page

logo代码需要进行一些修改。由于我想将徽标添加到已有的数字窗口中,因此我删除了创建新数字窗口的代码。我还更改了徽标轴的一些属性:'Parent' property已设置为当前数字窗口(GCF),'Units' property已设置为“像素”,并且'Position' property已更改为将徽标轴置于心轴旁边数字窗口。

全部放在一起,这里的新I_Heart_MATLAB代码来生成上图:

function I_Heart_MATLAB 

    % Initialize heart plot and adjust figure and axes settings: 

    heart; 
    set(gcf,'Position',[200 200 640 300],'Name','Original image'); 
    offset = get(gca,'CameraPosition')-get(gca,'CameraTarget'); 
    offset = 35.*offset./norm(offset); 
    set(gca,'Position',[65 -9 300 300],'CameraViewAngle',6,... 
     'XLim',[21+offset(1) 70],'YLim',[16+offset(2) 63],... 
     'ZLim',[32 81+offset(3)]); 

    % Create the axes and labels, offsetting them in front of the 
    % heart to give the appearance they are passing through it: 

    arrowStarts = [81 51 51; 51 86 51; 51 51 32]+repmat(offset,3,1); 
    arrowEnds = [21 51 51; 51 16 51; 51 51 81]+repmat(offset,3,1); 
    arrow(arrowStarts,arrowEnds,5,40,40); 
    text('Position',[22 52 48]+offset,'String','x','FontSize',12); 
    text('Position',[50 17 49]+offset,'String','y','FontSize',12); 
    text('Position',[46.5 51 81.5]+offset,'String','z','FontSize',12); 

    % Create the equation text: 

    text('Position',[51 47 28],'FontName','Bookman','FontSize',8,... 
     'HorizontalAlignment','center',... 
     'String',{'(x^2+^9/_4y^2+z^2-1)^3-x^2z^3-^9/_{80}y^2z^3=0'; ... 
       '-3 \leq x,y,z \leq 3'}); 

    % Create the large-type text: 

    hI = text('Position',[4 52 69.5],'String','I',... 
      'FontAngle','italic','FontName','Trebuchet MS',... 
      'FontSize',116,'FontWeight','bold'); 

    % Create and plot the L-shaped membrane logo: 

    logoData = 40*membrane(1,25); 
    logoAxes = axes('Parent',gcf,'Units','pixels',... 
        'Position',[335 21 280 280],... 
        'CameraPosition', [-193.4013 -265.1546 220.4819],... 
        'CameraTarget',[26 26 10],'CameraUpVector',[0 0 1],... 
        'CameraViewAngle',9.5,'DataAspectRatio',[1 1 .9],... 
        'XLim',[1 51],'YLim',[1 51],'ZLim',[-13 40],... 
        'Visible','off'); 
    surface(logoData,'Parent',logoAxes,'EdgeColor','none',... 
      'FaceColor',[0.9 0.2 0.2],'FaceLighting','phong',... 
      'AmbientStrength',0.3,'DiffuseStrength',0.6,... 
      'Clipping','off','BackFaceLighting','lit',... 
      'SpecularStrength',1.1,'SpecularColorReflectance',1,... 
      'SpecularExponent',7); 
    light('Parent',logoAxes,'Position',[40 100 20],'Color',[0 0.8 0.8],... 
     'Style','local'); 
    light('Parent',logoAxes,'Position',[.5 -1 .4],'Color',[0.8 0.8 0]); 

    % Create an anti-aliased version of the figure too (the larger 
    % fonts need some adjustment to do this... not sure why): 

    set(hI,'FontSize',86); 
    myaa; 
    set(hI,'FontSize',116); 
    set(gcf,'Name','Anti-aliased image'); 

end 
+0

如何定义'位置'?它取决于坐标还是网格线?仍然模糊? – izzat 2009-10-22 13:06:50

相关问题