如何在MATLAB中将MathWorks徽标添加到图像中?
我曾在一次会议上问过如何在MATLAB中重现。现在,我想通过删除单词“Math”并用替换来修改该图像 我不知道如何将徽标添加到图形中并调整其位置 以下是我一直尝试使用的代码,用于将徽标添加到图形中:如何在MATLAB中将MathWorks徽标添加到图像中?,matlab,Matlab,我曾在一次会议上问过如何在MATLAB中重现。现在,我想通过删除单词“Math”并用替换来修改该图像 我不知道如何将徽标添加到图形中并调整其位置 以下是我一直尝试使用的代码,用于将徽标添加到图形中: L = 40*membrane(1,25); logoFig = figure('Color',[1 1 1]); logoax = axes('CameraPosition', [80.5 50 42.5],... 'CameraTarget',[26 26 10], ... '
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
你似乎很难弄明白这一点。以下是我假设您要生成的图像: 首先,我从我发布的函数
heart
和I_heart\u Math
开始(它们使用和来自)。我删除了I\u Heart\u Math
中与绘制“Math”一词相关的所有代码,并缩小了图形窗口的大小
接下来,我必须生成并绘制MATLAB L形薄膜徽标。在MATLAB中,您可以键入logo
,它将打开一个新图形,其中logo显示在黑色背景上。您可以通过在MATLAB中键入type logo
查看生成图形的代码,也可以查看
徽标
代码需要进行一些修改。因为我想将徽标添加到已经存在的图形窗口中,所以我删除了创建新图形窗口的代码。我还更改了徽标轴的一些属性:设置为当前图形窗口(),设置为“像素”,并更改为在图形窗口中将徽标轴定位在心脏轴旁边
总而言之,这里是新的I_Heart\u 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
如何定义“位置”?这取决于坐标、网格线还是什么?仍然模糊不清???@izzat:我不愿意再帮你了,因为你很可能会在得到答案后删除这个问题,就像你以前做的那样。堆栈溢出的意义不仅在于回答您的问题,还在于创建一个编程帮助库,供其他人使用。如果你想自私,不让别人看,为什么我要花很大的精力发布一个答案?我命令设置“位置”,我必须“看看”将我想要的数字放在哪里。我怎么能“看见”呢?当我尝试它的时候,仍然有很多数字出来……我保证我会表现得很好的……@izzat:好吧,我给你一次机会来赎罪。但请注意。。。如果我花时间和精力回答你的问题,而你立即删除它,我将抵制你在这里发布的所有内容,直到时间停止=P