region of interest mouse click response and if statements using psychtoolbox-3

2 views (last 30 days)
Hi All,
I'm wondering how I can specify a region of interest on an image using Psychtoolbox-3. I need the ROI to be invisible to the user. I would like the user to make a left mouse click and then use an if statement (that depends on whether they clicked inside or outside of the ROI) to determine what happens next. PLEASE HELP!!
I currently have this, but it's not working (i'm not even sure if the load function is calling the roi back):
%I used drawrectangle to make an roi on an image and then saved it to roi.mat
load('roi.mat')
[clicks,x,y,WhichButton] = GetClicks;
if inROI(roi,x,y)
texture = Screen('MakeTexture', windowPtr, YouWon);
Screen('DrawTexture', windowPtr, texture);
Screen('Flip', windowPtr);
WaitSecs(1);
else
texture = Screen('MakeTexture', windowPtr, TryAgain);
Screen('DrawTexture', windowPtr, texture);
Screen('Flip', windowPtr);
WaitSecs(1);
end

Answers (1)

Srimouli Rukmabhatla
Srimouli Rukmabhatla on 26 Mar 2020
Hi Rubina,
Please do ensure that the required variables are loaded in ‘roi.mat’ file . inROI function is to check the given co-ordinates are within the Region Of Interest, If co-ordinates are within the ROI it return 1 else it return 0 .Please do refer the inROI doucumentaion link https://www.mathworks.com/help/images/ref/inroi.html.

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!