Matlab 图像(矩阵)中插入矩形框和文字

这里介绍的方法使用的是Matlab自带的Vision工具,使用方法是vision. 。

下面是个样例,matlab自带的:

画圆

i = imread('coins.png'); figure, imshow(i);

position = [96 146 31;236 173 26]; label = [5 10];

rgb = insertObjectAnnotation(i, 'circle', position, label,'color', {'cyan', 'yellow'}, 'textcolor', 'black');

figure, imshow(rgb), title('annotated coins');

Matlab 图像(矩阵)中插入矩形框和文字_第1张图片

画框:

i = imread('board.tif'); figure, imshow(i);

label_str = cell(3,1); conf_val = [85.212 98.76 78.342];

for ii=1:3

label_str{ii} = ['confidence: ' num2str(conf_val(ii),'%0.2f') '%'];

end

position = [23 373 60 66;35 185 77 81;77 107 59 26];

rgb = insertObjectAnnotation(i, 'rectangle', position, label_str,'textboxopacity', 0.9, 'fontsize', 18);

figure, imshow(rgb), title('annotated chips');

Matlab 图像(矩阵)中插入矩形框和文字_第2张图片

你可能感兴趣的:(学术)