1

I have a 2D matrix which has the size 65536 × 1, if I want to convert it to a 3D in MATLAB, first I should convert it to a 256 × 256, and then that 256 × 256 into an 3D.

Can anyone help me with that?

Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96
user3223551
  • 59
  • 1
  • 1
  • 7

1 Answers1

1

To convert your greyscale image (that somehow has been vectorized) into an RGB image, just copy the greyscale intensities into the RGB layers:

%// first, reshape
img = reshape(img, 256, 256);

%// then, copy
img = repmat(img, [1 1 3]);
Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96
  • `img` is... why not simply try it yourself? – tim Jan 22 '14 at 13:20
  • @user3223551: I've updated my answer to meet your demands. For future reference, this is a typical example of an [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem); please ask about your *original* problem, not about problems you encounter during your attempt to solve your original problem. Include your attempted solution, and why that fails. – Rody Oldenhuis Jan 22 '14 at 13:21