在MATLAB中将图像绘制为轴标签 [英] Plot images as axis labels in MATLAB

查看:109
本文介绍了在MATLAB中将图像绘制为轴标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用imagesc命令在MATLAB中绘制7x7像素的图像":

I am plotting a 7x7 pixel 'image' in MATLAB, using the imagesc command:

imagesc(conf_matrix, [0 1]);

这表示七个不同对象之间的混淆矩阵.我有一个我想用作轴刻度标签的七个对象中每个对象的缩略图.有没有简单的方法可以做到这一点?

This represents a confusion matrix, between seven different objects. I have a thumbnail picture of each of the seven objects that I would like to use as the axes tick labels. Is there an easy way to do this?

推荐答案

我不知道简单的方式.确定标签的轴属性XtickLabel只能是字符串.

I don't know an easy way. The axes properties XtickLabel which determines the labels, can only be strings.

如果您想要一种不太容易的方法,则可以本着以下不完整(就不完整解决方案而言)代码的精神来做一些事情,创建一个标签:

If you want a not-so-easy way, you could do something in the spirit of the following non-complete (in the sense of a non-complete solution) code, creating one label:

h = imagesc(rand(7,7));
axh = gca;
figh = gcf;
xticks = get(gca,'xtick');
yticks = get(gca,'ytick');
set(gca,'XTickLabel','');
set(gca,'YTickLabel','');
pos = get(axh,'position'); % position of current axes in parent figure

pic = imread('coins.png');
x = pos(1);
y = pos(2);
dlta = (pos(3)-pos(1)) / length(xticks); % square size in units of parant figure

% create image label
lblAx = axes('parent',figh,'position',[x+dlta/4,y-dlta/2,dlta/2,dlta/2]);
imagesc(pic,'parent',lblAx)
axis(lblAx,'off')

一个问题是标签将具有与原始图像相同的颜色图.

One problem is that the label will have the same colormap of the original image.

这篇关于在MATLAB中将图像绘制为轴标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆