Issues with greyscale png images in matlab

1 次查看(过去 30 天)
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!

采纳的回答

Dave B
Dave B 2021-10-18
编辑:Dave B 2021-10-18
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)
Or you can convert it to an rgb image using ind2rgb:
img_rgb = ind2rgb(img,cmap);
imshow(img_rgb)

更多回答(0 个)

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by