将MATLAB图形保存为矢量图像时的振铃效果

时间:2013-10-27 16:18:11

标签: matlab vector-graphics

当我将人工生成的图像保存为eps文件时,我会收到响铃效果。但是,当保存为png文件时,效果不可见。这是预期的吗?

提到的输出图像:

png输出:
png output

eps输出:
eps output

function displayMatrixAsImage(mat, labels);

len = size(mat,1);

if nargin < 2
labels = cell(len);
for k = 1:len
    labels{k} = num2str(k-1);
end
end

max_mat = sum(mat,2); % sum the number of times a target is in the test
m2 = mat ./ repmat(max_mat,1,size(mat,2)); % get the probabilities

imagesc(m2, [0 1]);            %# Create a colored plot of the matrix values
colormap(flipud(gray));  %# Change the colormap to gray (so higher values are
                     %#   black and lower values are white)

% textStrings = num2str(mat(:),'%0.0f');  %# Create strings from the matrix values
textStrings = num2str(100*m2(:),'%0.0f');  %# Create strings from the matrix values
textStrings = strtrim(cellstr(textStrings));  %# Remove any space padding

[x,y] = meshgrid(1:len);   %# Create x and y coordinates for the strings
hStrings = text(x(:),y(:),textStrings(:),...      %# Plot the strings
            'HorizontalAlignment','center',...
            'FontSize', 18);
midValue = mean(get(gca,'CLim'));  %# Get the middle value of the color range
textColors = repmat(m2(:) > midValue,1,3);  %# Choose white or black for the
                                         %#   text color of the strings so
                                         %#   they can be easily seen over
                                         %#   the background color
set(hStrings,{'Color'},num2cell(textColors,2));  %# Change the text colors

set(gca,'XTick',1:len,...                         %# Change the axes tick marks
    'XTickLabel',{labels{1},labels{2}},...  %#   and tick labels
    'YTick',1:len,...
    'YTickLabel',{labels{1},labels{2}},...
    'TickLength',[0 0]);
ylabel('true label');
xlabel('predicted label');

0 个答案:

没有答案