Issues with greyscale png images in matlab
3 views (last 30 days)
Show older comments
Caroline Harbison
on 18 Oct 2021
Commented: Caroline Harbison
on 18 Oct 2021
I have a number of greyscale png images of faces (from a free dataset) that I am using as part of a Psychtoolbox experiment. In photo apps such as preview they all look okay, but when I open them in MATLAB several of them are pixelated and the colours are off so they are unusable (see attached photos). Any suggestions as to why this might be?
Thanks!
2 Comments
Accepted Answer
Dave B
on 18 Oct 2021
Edited: Dave B
on 18 Oct 2021
This looks like the result of loading an indexed image, you can read the colormap using the second output of imread:
[img,cmap]=imread('image.png');
imshow(img,cmap)
img_rgb = ind2rgb(img,cmap);
imshow(img_rgb)
More Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!