getitemimgallrot.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. function Jcenter = getitemimgallrot(i,sizegaz,resize);
  2. for k =1:16;
  3. rotlist = linspace(11.25,348.75,16)
  4. % rotlist=[11.2500000000000
  5. % 56.2500000000000
  6. % 101.250000000000
  7. % 146.250000000000
  8. % 191.250000000000
  9. % 236.250000000000
  10. % 281.250000000000
  11. % 326.2500000000000];
  12. % i=1
  13. % sizegaz=[400 400]
  14. % resize=2
  15. % Get the image files for the experiment:
  16. imageFolder = 'stimuli/';
  17. imgList = dir(fullfile(imageFolder,['*.' 'jpg']));
  18. imgList = {imgList(:).name};
  19. bth=254;% treshold to subtitute for background
  20. sc_o=(10000/2560)*1.4;
  21. %Object 1
  22. file_object_1 = imgList{i};
  23. img_object_1 = imread(fullfile(imageFolder ,file_object_1));
  24. img_object_1((img_object_1>=bth))=255;%128; %REMOVING BACKGROUND FOR EACH IMAGE
  25. % objectDisplay_1 = Screen('MakeTexture', window1, img_object_1);
  26. % Calculate image position (center of the screen) OBJECT 1
  27. imageSize_o1 = size(img_object_1)/sc_o;
  28. % pos_o1 = [(W-imageSize_o1(2))/2 (H-imageSize_o1(1))/2 (W+imageSize_o1(2))/2 (H+imageSize_o1(1))/2];
  29. J = imresize(img_object_1,imageSize_o1(1:2));
  30. if resize==1 %if the plot is smaller than the images
  31. n=round(sizegaz/2);
  32. m=round(size(J)/2);
  33. point1=m(1)-n(1);
  34. point2=m(1)+n(1);
  35. Jcenter=J(point1:point2,point1:point2,:);
  36. elseif resize==2 %if the plot is bigger than the images
  37. m=round(sizegaz/2);
  38. n=round(size(J)/2);
  39. point1=m(1)-n(1);
  40. point2=m(1)+n(1);
  41. canvas=nan([sizegaz,3]);
  42. canvas(:,:,:)=256;
  43. canvas(point1:point2-1,point1:point2-1,:)=J(:,:,:);
  44. canvas=uint8(canvas);
  45. Jcenter=canvas;
  46. else
  47. Jcenter=J;
  48. end
  49. JcenterRot=imrotate(Jcenter,rotlist(k),'nearest','crop');
  50. im=imagesc(JcenterRot);
  51. % im.AlphaData = 0.35;%min(JcenterRot,[],2);
  52. alphamap=JcenterRot(:,:,1)~=255;
  53. alphamap=alphamap.*(1/(k));
  54. im.AlphaData =alphamap;
  55. hold on;
  56. end
  57. end