Main Content

Select String to Insert into Image

This example shows you how to select a text string and insert it into an image when the Insert Text block contains multiple text strings.

Example Model

Open the Simulink® model.

modelname = 'ex_blkInsertTextSelect.slx';

This model reads an input image using an Image From File block with the File name parameter set to yellowlily.jpg.

The block selects and inserts a text string into the input image by using an Insert Text block with these parameters:

  • Text{'Lilly 1','Lilly 2'}

  • Color value sourceSpecify via dialog

  • Color value[255,255,0]

  • Location sourceSpecify via dialog

  • Location [x y][600,50]

  • Opacity1

  • Font faceLucidaSansDemiBold

  • Font size (points)100

A Manual Switch (Simulink) block enables you to select which input string to display.

Simulate Model

Run the model. The model displays the output image with inserted bold, yellow text by using a Video Viewer block. Double-click the Manual Switch (Simulink) block to select the other string and display an output image with that string inserted.