0

I have an image typed double in Matlab. How can I imshow it? Thanks.

load('file.mat');
b=d.l{2,1}.a{1,1}; %//b is an image <96x96x4 double>
imshow(b);
Shai
  • 111,146
  • 38
  • 238
  • 371
Dani
  • 41
  • 1
  • 5
  • 3
    `imshow` doesn't support showing 4 channel images. What is this image supposed to represent? – rayryeng Oct 19 '15 at 04:58
  • if your image is `NxMx3`, and you made a typo in the comment, use `imshow(b,[])` to autoadjust the limits of the `imshow` function – Ander Biguri Oct 19 '15 at 09:49

1 Answers1

1

As @rayryeng suggests, imshow does not like 4 channel images. Thus:

If your image is NxMx3, and you made a typo in the comment, use imshow(b,[]) to auto-adjust the limits of the imshow function.

If your 4th channel is alpha, then either ignore the alpha: imshow(b(:,:,1:3),[])

Or, convert your image from RGBA to the closest representation in RGB. You can do that with something called alpha blending, and you have a nice answer (in another programming language) in this SO post: Convert RGBA color to RGB

If neither of these is your case, then you may want to give more information.

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
  • Yes, you are right Ander Biguri. It worked when I ignored the alpha channel. Thanks. – Dani Oct 19 '15 at 15:29
  • What about If I want to show an image 25x25 double instead of 96x96x4. I tried to use the imshow function, but it didn't work and shows an error as the following: Index exceeds matrix dimensions. Thanks – Dani Oct 19 '15 at 15:43
  • @Dani the size of the image does not have absoutely no influence in `imshow`, so if it didnt work, there is another reason. – Ander Biguri Oct 19 '15 at 15:44