Labelling images on the screen

I have three images displayed in the middle of the screen, one on the center and the other two appear on either side. i want to label each image right below it. how to use ‘DrawText’ to implement it such that specified location is right below its corresponding image.

Have at look at DrawFormattedText2:

http://psychtoolbox.org/docs/DrawFormattedText2

That offers lots of advanced options to manage position and lots of other formatting options. Read through the demo for that function. If you want something simpler, then type Screen DrawText? in the MATLAB command window and read the help, this is the underlying command that allows you to pass X and Y coordinates, but doesn’t handle wrapping or other nicities that DrawFormattedText2 does…

1 Like

I’m unable to run the demo.When i run it on the command window. I’m getting this error ‘PTB - ERROR: SYNCHRONIZATION FAILURE’. any idea why?

Without knowing anything about your OS or computer, no. Read what PTB returns, and you’ll see it recommends reading this documentation:

>> doc SyncTrouble

For development you can ignore this (you’ll find the override by reading the documentation), but if you care about timing for the actual experiment, it is wise to follow the recommendations. You will have the least problems if you use Linux for your experimental control computer…

1 Like

Thanks. I sorted out the synchronization problem. As my images keep changing throughout. And I need the labels to correspondingly change with them, I thought it’s better overlay the text on the image. Is there any function which enables that?

Yes, you can just use drawtext or any if the other text functions to draw on tip of the images, by simply doing the drawtext call after the drawtexture call.

1 Like

Thanks. but i dont get how i can specify the location for the text. I have a vector of texture points for the images of three continents. I want the text to appear below each of them. i tried to make a vector of texts like

text_T=['europe' 'southamerica 'africa']

Screen('DrawTextures', window,T,[],rects);
Screen('DrawText',window,text_T,?)

Read the documentation:

http://psychtoolbox.org/docs/Screen-DrawText

or

http://psychtoolbox.org/docs/DrawFormattedText2
https://raw.githubusercontent.com/Psychtoolbox-3/Psychtoolbox-3/beta/Psychtoolbox/PsychDemos/DrawFormattedText2Demo.m

That tells you where you need to enter your X and Y position, though note I think neither are vectorised, you need to call them 3 times for 3 labels, or use spaces/tabs to align the labels in one char array.