From: Z A on 16 May 2010 10:18 Hello, I would like to convert a m x n x 9 matrix into m x n x 3 matrix. May anyone kindly assist me in doing so. Best Z
From: Michael_RW on 16 May 2010 10:59 Try "reshape". --- frmsrcurl: http://compgroups.net/comp.soft-sys.matlab/matrix-conversion
From: Roger Stafford on 16 May 2010 12:51 "Z A" <nospam-rekabi570(a)yahoo.ca> wrote in message <hsouqr$qoj$1(a)fred.mathworks.com>... > I would like to convert a m x n x 9 matrix into m x n x 3 matrix. There are three elements in the former for every one element in the latter. In what way would you like to combine each three elements into one? Or do you want to discard 6*m*n of them, and if so which ones? Roger Stafford
From: Z A on 16 May 2010 13:15 I tried reshape however I get an error, obviously because I want a M x N x 3 and so I will not hav ethe same elements. This is what I want: I have an image which is composed of 420 x 560 x 3 unit8, I can do womething like rgb2gray to get 420 x 560 double. However my second image is 420 x 560 x 9, I cannot overlay that as a transperency onto the first one, because the dimensions are different, what I want is to change that matrix to 420 x 560 x 3 so I can do that without losing any info. I hope you understood what I need. Thank you in advance. Z "Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hsp7po$pkg$1(a)fred.mathworks.com>... > "Z A" <nospam-rekabi570(a)yahoo.ca> wrote in message <hsouqr$qoj$1(a)fred.mathworks.com>... > > I would like to convert a m x n x 9 matrix into m x n x 3 matrix. > > There are three elements in the former for every one element in the latter. In what way would you like to combine each three elements into one? Or do you want to discard 6*m*n of them, and if so which ones? > > Roger Stafford
From: Walter Roberson on 16 May 2010 14:16 Z A wrote: > I tried reshape however I get an error, obviously because I want a M x N > x 3 and so I will not hav ethe same elements. > This is what I want: > I have an image which is composed of 420 x 560 x 3 unit8, I can do > womething like rgb2gray to get 420 x 560 double. However my second image > is 420 x 560 x 9, I cannot overlay that as a transperency onto the first > one, because the dimensions are different, what I want is to change that > matrix to 420 x 560 x 3 so I can do that without losing any info. The first image is x 3 because it is a true-color image, with the third dimension being red, green, and blue. The second image... x 9 is either a mistake or an indication that it is really 9 grayscale or indexed images stacked together. The only way to pack down a 420 x 560 x 9 matrix to 420 x 560 x 3 matrix without losing any information is by representing the information differently, such as new(:,:,1) = old(:,:,1) * 65536 + old(:,:,2) * 256 + old(:,:,3); new(:,:,2) = old(:,:,4) * 65536 + old(:,:,5) * 256 + old(:,:,6); and so on. However, data packet in such a manner would not be suitable for use as a transparency. You are going to have to explore _why_ the second image is x 9; it is fairly unlikely that it represents a single image.
|
Next
|
Last
Pages: 1 2 Prev: tiled texture mapping Next: Call for Paper, Special Issue on Cognitive Information Processing |