title: Why, when displaying a greyscale .png file in Psychtoolbox (with an alpha channel), is the image displaying in bright red?
body: <p>I am currently preparing some greyscale .png images that will be displayed in Psychtoolbox. These .png files all have transparent backgrounds, and so I've been adding in the alpha layer into the file matrix like so:</p>
  
  <pre><code>% sets up for the alpha
  Screen('BlendFunction', w, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
  
  [pngImage,~,alpha] = imread('image.png'); % read in the image
  pngImage(:,:,4) = alpha; % add in the alpha channel
  pngTexture = Screen('MakeTexture',w, pngImage); % create image texture
  </code></pre>
  
  <p>When displaying these images, the background is indeed transparent. However, they also present as <a href="https://imgur.com/MMee0S5" rel="nofollow noreferrer">bright red instead of greyscale</a> (link to image). When I comment out the line of code that adds in the alpha channel, the background is no longer transparent, but <a href="https://imgur.com/qosGQJb" rel="nofollow noreferrer">it is in greyscale</a> (link to image).</p>
  
  <p>Some of the images in the set present just fine, with no problem. Those images were batch-processed in Photoshop. The images that present the issue appear to be images that were hand-processed in GIMP. However, the entire image set presents just fine in Psychopy. (Writing this project in Psychopy is not an option, due to time constraints and some MATLAB-specific functions required.)</p>
  
  <p>If I had to guess, with my <em>extremely</em> limited knowledge, I'd say that adding the fourth 2D matrix into the image matrix is setting off the argument that multiplies colour values. However, I've no idea how. Anyone got any thoughts?</p>