alternative approach of "insertObjectAnnotation" function
조회 수: 38 (최근 30일)
이전 댓글 표시
Hi:
I'm doing some stock analysis, I use Matlab to plot 4 different figures and connect them together. then I would like to add a customized description.
I found in order to add the text on an image I need to buy computer vision toolbox... so come here to ask if there is any alternative approach to add cusotmized text in the figure attached.
Thanks!
Yu

댓글 수: 0
채택된 답변
cui,xingxing
2025년 9월 9일 1:37
편집: cui,xingxing
2025년 9월 9일 1:49
You can use the title built-in function(only require MATLAB) to set a custom title — it is designed for graphics objects — instead of using insertObjectAnnotation, which directly adds a text-shaped annotation onto the image and returns the resulting RGB image array.
Additionally, if you want to customize the title position, you can also try the text built-in function(only require MATLAB) to place a custom title at specified coordinates.
Example:
figure;
t = tiledlayout(2,2);
% Tile 1
nexttile
plot(rand(1,20))
title('Your Title 1')
% Tile 2
nexttile
plot(rand(1,20))
title('Your Title 2')
% Tile 3
nexttile
plot(rand(1,20))
title('Your Title 3')
% Tile 4
nexttile
plot(rand(1,20))
title('Your Title 4')
title(t,"customized text here",FontSize=20,FontWeight="bold")
댓글 수: 2
cui,xingxing
2025년 9월 9일 3:23
Do not use subplot; it is an outdated function. Please use tiledlayout instead — it lets you control the spacing between different axes(TileSpacing).
추가 답변 (1개)
Walter Roberson
2025년 9월 9일 5:00
insertObjectAnnotation from the Computer Vision Toolbox is used to insert text into an array, retaining full resolution of the array. The resulting array is suitable for writing out at full resolution to file using imwrite() or similar. There is no need to display the image at any point when using this function.
You can also choose to display the image and use functions such as title() and text(). These work well if your final destination is the displayed image.
However, if your final destination is writing to an image file, then using functions such as title() and text() requires that you capture plotted information using getframe . getframe() works at whatever resolution the axes were displayed at, which is typically either larger or smaller than the original image resolution. getframe() is not suited at all for retaining the original image resolution.
If you need to retain the original image resolution, then the tools of the Computer Vision Toolbox are the only supported functions.
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!