Insert Two Strings into Image at Different Locations
This example shows you how to insert two strings of different colors into an image at different location within the image.
Example Model
Open the Simulink® model.
modelname = 'ex_blkInsertTextLocation.slx';
open_system(modelname)
This model reads an input image using an Image From File block with the File name parameter set to yellowlily.jpg
.
The model inserts two strings into the input image at different locations by using the Insert Text block with these parameters:
Text —
'%s'
Color value source —
Input port
Location source —
Specify via dialog
Location [x y] —
[300 250;100 1400]
Opacity —
1
Image signal —
One multidimensional signal
Font face —
LucidaSansDemiBold
Font size (points) —
100
The Specify two variables
Constant (Simulink) block changes the text of the inserted strings, and the Specify two color source
Constant (Simulink) block changes their color.
Simulate Model
Run the model. The model uses a Video Viewer block to display the output image with an inserted pair of bold text strings in different colors and at different locations.
sim(modelname);