# Collecting Image Dataset into a variable dimension mismatch problem

1 visualización (últimos 30 días)
ken ken el 18 de Dic. de 2015
Comentada: Dima Lisin el 19 de Dic. de 2015
Supoosed i Have declare a Maxtrix variable
train_x = zeros(64,128,3,15);
The train_x variable is 4-D double. which store up to 15 images it is a image dataset
I have an Images whose dimensions are 64 x 128 x 3 uint8 and 64 x 128 uint8
Res_none = imresize(Img_none, [64 128]); % -> where Res_none is 64 x 128 uint8
test_x(:,:,:,1) = Res_none; % <- due to insufficient dimension
I am trying to store an image into the train_x 4-D array but because images is 64 x 128 uint8, but it is insufficient dimension to store because it only stores an image whose dimensions are 64 x 128 x 3 uint8.
Is it possible that I can store that image 64 x 128 uint8 to the train_x (dataset) so that I can retrieve that same file from train_x (dataset)?
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
jgg el 18 de Dic. de 2015
Why not just declare train_x = zeros(64,128,8,15) instead?
I don't think you're going to be able to store a 64x128 image with 8 bits of information per pixel into a 62x128x3 matrix without collapsing the 8 bits down.
Since 8 bits is only 2^8, could you not convert it to an integer, then store the integer instead of storing it bitwise?

Iniciar sesión para comentar.

Dima Lisin el 18 de Dic. de 2015
If you are trying to store 15 RGB images of size 64 x 128 x 3, the tran_x should have the size [64,128,3,15], exactly like you have it. You may also want to make it a uint8 array from the start, like this:
train_x = zeros([64,128,3,15], 'uint8');
If you want to store 15 grayscale images of size 64 x 128, then train_x should have the size of [64, 128, 15].
If some of your images are RGB and some are grayscale, then there are several things you can do. You could make all images RGB.
imgRGB = cat(3, imgGray, imgGray, imgGray);
Then all of your images will have the size 64x128x3. Alternatively, you can use a cell array to store the images. Elements of a cell array can have different sizes and even data types.
##### 2 comentariosMostrar NingunoOcultar Ninguno
ken ken el 19 de Dic. de 2015
my imgGray is 64 x 128 unint8
after using this commands
imgRGB = cat(3, imgGray, imgGray, imgGray);
the result of the imgRGB value is 64 x 128 x 9 unint8
how may i make it to 64 x 128 x 3 unint8 so that i am able put into the train_x dataset
Dima Lisin el 19 de Dic. de 2015
Wait, if your result is 64 x 128 x 9, then imgGray must be 64 x 128 x 3.

Iniciar sesión para comentar.

### Categorías

Más información sobre Image Arithmetic en Help Center y File Exchange.

### Etiquetas

Aún no se han introducido etiquetas.

### Community Treasure Hunt

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

Start Hunting!

Translated by