123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- function Jcenter = getitemimg(i,sizegaz,resize);
- % Get the image files for the experiment:
- imageFolder = 'stimuli/';
- imgList = dir(fullfile(imageFolder,['*.' 'jpg']));
- imgList = {imgList(:).name};
- bth=254;% treshold to subtitute for background
- sc_o=(10000/2560)*1.4;
- %Object 1
- file_object_1 = imgList{i};
- img_object_1 = imread(fullfile(imageFolder ,file_object_1));
- img_object_1((img_object_1>=bth))=256;%128; %REMOVING BACKGROUND FOR EACH IMAGE
- % objectDisplay_1 = Screen('MakeTexture', window1, img_object_1);
- % Calculate image position (center of the screen) OBJECT 1
- imageSize_o1 = size(img_object_1)/sc_o;
- % pos_o1 = [(W-imageSize_o1(2))/2 (H-imageSize_o1(1))/2 (W+imageSize_o1(2))/2 (H+imageSize_o1(1))/2];
- J = imresize(img_object_1,imageSize_o1(1:2));
- if resize==1 %if the plot is smaller than the images
-
- n=round(sizegaz/2);
- m=round(size(J)/2);
- point1=m(1)-n(1);
- point2=m(1)+n(1);
- Jcenter=J(point1:point2,point1:point2,:);
- elseif resize==2 %if the plot is bigger than the images
-
- m=round(sizegaz/2);
- n=round(size(J)/2);
- point1=m(1)-n(1);
- point2=m(1)+n(1);
-
- canvas=nan([sizegaz,3]);
- canvas(:,:,:)=256;
- canvas(point1:point2-1,point1:point2-1,:)=J(:,:,:);
- canvas=uint8(canvas);
- Jcenter=canvas;
-
- else
- Jcenter=J;
- end
- end
|