次のコード セグメントでは、図のピクセル座標 (行と列) に対するテキスト境界ボックスの正確な位置を取得して、最終的に図のその部分を (配列 img から) トリミングできるようにしようとしています。しかし、私が textBox から得るものはあまり役に立ちません! いくつかの負の数!! 誰でも私にいくつかのヒントを提供できますか
hFigure = figure('Color', 'w','position',...
[1600 200 600 250]...
,'MenuBar', 'none', 'ToolBar', 'none');
axis off
axis([0 1 0 1]);
hText=text('String','T','fontsize',100,'color','r',...
'fontname','Times New Roman',...
'HorizontalAlignment','left','VerticalAlignment','bottom',...
'BackgroundColor',[.8 .8 .8],'EdgeColor','b');
set(hText, 'Units','Pixels');
textBox=get(hText, 'Extent');%[left,bottom,width,height]
figBox = get(hFigure,'Position');
imageData = getframe(hFigure);
img = imageData.cdata;
%using textBox and imgBox:
imgText=img(?:?,?:?,3); **% this is what I want to do**