matlab直接在图上加图注,MATLABinsertShape图像上直接添
加图像
官⽅说明⽂档
⽤figure 和plot的⽅式⽆法直接在原图上做标记,且图像会根据窗⼝的⼤⼩做压缩。
insertShape就类似于opencv中的rectangle,circle 等函数的集成了~~~
I = imread('peppers.png'); % where
RGB = insertShape(I, 'circle', [150 280 35], 'LineWidth',20);
pos_triangle = [183 297 302 250 316 297];
pos_hexagon = [340 163 305 186 303 257 334 294 362 255 361 191];
RGB = insertShape(RGB, 'FilledPolygon', {pos_triangle, pos_hexagon}, 'Color', {'white', 'green'}, 'Opacity', 0.7);
imshow(RGB);
%insert mark
I = imread('peppers.png');
%Draw a plus (+).
RGB = insertMarker(I, [147 279]);
%Draw four x-marks.
pos = [120 248;195 246;195 312;120 312];
color = {'red', 'white', 'green', 'magenta'};
RGB = insertMarker(RGB, pos, 'x', 'color', color, 'size', 10);
% Display the image.
figure
imshow(RGB);
% insert text
%Read the image.
I = imread('board.tif');
%Create texts that contain fractions.
text_str = cell(3,1);
conf_val = [85.212 98.76 78.342];
for ii=1:3
text_str{ii} = ['Confidence: ' num2str(conf_val(ii),'%0.2f') '%'];
end
%Define positions and colors.
position = [23 373;35 185;77 107];
box_color = {'red','green','yellow'};
%Insert text.
RGB = insertText(I,position,text_str,'FontSize',18,'BoxColor',box_color,'BoxOpacity',0.4);
%Display the image.
figurerectangle函数opencv
imshow(RGB)
title('Board');
%% insertObjectAnnotation
I = imread('coins.png');
figure, imshow(I);
%Set up the circle annotations with labels. The first two arguments are the (x,y) coordinates for the center of the circle, the third argument is the radius.
position = [96 146 31;236 173 26];
label = [5 10];
%Insert the annotation.
RGB = insertObjectAnnotation(I, 'circle', position, label,'Color', {'cyan', 'yellow'}, 'TextColor', 'black');
%Display the annotated image.
figure, imshow(RGB), title('Annotated coins');

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。