在MATLAB中,如何使用图像注释图形?

时间:2011-04-14 19:08:53

标签: image matlab annotations

我想在特定点上将图像叠加在我的图形上方。 例如我希望在一个600px X 600px数字的归一化点[0.20,0.50]处绘制“cherry.png”[24px X 24px]。 我可以访问图像处理工具箱,我知道“imread()”,但我不清楚如何在特定点叠加。我应该查看的任何想法/参考文献?

1 个答案:

答案 0 :(得分:3)

如果您希望24 x 24像素的图像在标准化点(0.2,0.5)(相当于(120,300)像素)居中,那么您可以创建一个axes object是24 x 24像素并以您的点为中心,并使用IMAGE功能将图像添加到轴。例如:

img = imread('cherry.png');  %# Read the data from your image file
hFigure = figure('Position',[100 100 600 600]);  %# Make the figure window
hAxes = axes('Parent',hFigure,...          %# Add the axes to the figure
             'Units','pixels',...          %#   with units of pixels
             'Position',[108 288 24 24]);  %#   so the position is easy to define
hImage = image(img,'Parent',hAxes);  %# Plot the image
set(hAxes,'Visible','off');          %# Turn the axes visibility off

请注意,当我使用IMREAD加载图像数据时,我认为它是3-D RGB image。如果是indexed image,则必须从IMREAD获取其他颜色地图输出,以便convert the indexed image to an RGB image