0

I have a bunch of depth map images which are all png files. I need to use these in matlab. When I use imread, I get the image to have the following dimensions, h*w*3. Since it is a depth map, I think it should have only h and w but since it is in .png format, I think the 3rd dimension is included. How do I convert this back to 2 dimensions? Can I use rgb2gray? Is that sensible and why?

userJS
  • 99
  • 1
  • 10

1 Answers1

0

It has a 3rd dimension probably because your image is True Color or RGB image. As Mark Ransom say, if you do rgb2gray it will give the same picture but as 2D, only if all the 3 components are same. (i.e) only if a gray image is stacked three times as *.png, and if you do rgb2gray you will obtain the same image without any change but as a 2 Dimension.
Read this answer and this and this.

Community
  • 1
  • 1
Santhan Salai
  • 3,848
  • 17
  • 29