2011-04-14 32 views
2

我想在一個特定的點上疊加我的身影頂部的圖像。我想要在600px X 600像素的歸一化點[0.20,0.50]處繪製「cherry.png」[24px X 24px]。 我可以訪問圖像處理工具箱,並且我知道「imread()」,但是我不清楚如何在特定點上進行疊加。我應該檢查的任何想法/參考?在MATLAB中,如何用圖像註釋圖形?

回答

3

如果你希望你的24 * 24像素的圖像是在歸點(0.2,0.5)(相當於像素(120,300)),那麼你可以創建一個axes object是24 * 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加載的圖像數據I假定這是一個3-d RGB image。如果它是indexed image,則必須從IMREAD獲得附加彩色地圖輸出,以便您可以convert the indexed image to an RGB image

+0

這工作就像一個魅力。非常感謝@gnovice! – Derek 2011-04-14 20:23:14