2013-03-13 179 views
0

我想使用Scilab在图像中添加文本;起初我想用SIVP imshow,但事实证明这个函数不会返回句柄。 IPD对另一方面ShowImage不会返回的句柄,所以我想我可能只是这样做:Scilab,将图像添加到图像

sceneImgFigure = ShowColorImage(sceneImg,"Scene"); 

for k=1:size(inspectedScene) 
    uicontrol(sceneImgFigure, ... 
       "style", "text", ... 
       "string", mtlb_num2str(inspectedScene(k).alocated_label), ... 
       "position", [inspectionModel(k).centroid(1) inspectionModel(k).centroid(2) 20 20], ... 
       "fontsize",15, ... 
       "BackgroundColor",[0.9,0.9,0.9]); 
end 

但使用uicontrol我用图形的坐标,而不是图像坐标,导致文本在错误的地方被显示。除此之外,ShowImage裁剪图像。在这里我得到什么:

enter image description here

我无法找到Scilab的的帮助任何相关的答案,所以我有种陷在这里。有一个way做我想在Matlab中做的,但代码似乎不可能转换为Scilab(Scilab中没有文本或getframe函数,首先...)。

有什么想法?

回答

0

这里是我做过什么来解决这个(只是在情况下,它可能是哪天有用的人):

ShowColorImage(sceneImg,"Scene"); 
for i=1:size(inspectedScene) 
    xstring(inspectedScene(i).centroid(1)-5, ... 
      size(classDispImg,1)-inspectedScene(i).centroid(2)-5, ... 
      mtlb_num2str(inspectedScene(i).alocated_label)); 
    e = gce(); 
    e.font_size = 1; 
    e.font_foreground = color(0,0,0); 
end 

其中给出:

enter image description here

我得到的解决方案的一部分来自Scilab用户邮件列表。正如xenoclast所说,我想我必须使用图像高度来缩放y坐标。

1

我使用xstring根据绘图坐标系将注释放在绘图上。根据基本图像的格式,您可以使用imageplot(来自我认为的SIVP)绘制图像,其中我相信图像像素会映射到绘制坐标。

xstring(inspectionModel(k).centroid(1), inspectionModel(k).centroid(2), mtlb_num2str(inspectedScene(k).alocated_label)) 

如果您不能使用imgplot您可能需要手动缩放所有的坐标。它没有听起来那么糟糕 - 如果您知道图像的大小,可以计算出坐标系的比例因子。我做了这样的事情,所以当使用小波工具箱做谱图时,我可以将轴放到imageplot上。