How to convert images to vectors
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    M
 el 17 de Oct. de 2023
  
    
    
    
    
    Comentada: Walter Roberson
      
      
 el 17 de Oct. de 2023
            How can I convert my images with size    120   160     1   888 to vectors ?
where 120* 160 is the size of each gray scale image, 1 is the number of channels, 888 is the number of images
so the output will be matrix and each column in the matrix is an image, I should end up with 888 vectors each vector is image
0 comentarios
Respuesta aceptada
  Dyuman Joshi
      
      
 el 17 de Oct. de 2023
        From what I have understood - 
%Random input
in = rand(120,160,1,888);
s = size(in);
%Convert the input to a cell vector
out = mat2cell(in,s(1),s(2),s(3),ones(1,s(4)));
size(out)
%Modify the size of the output 
out = squeeze(out)
6 comentarios
  Walter Roberson
      
      
 el 17 de Oct. de 2023
				in = rand(120,160,1,888);
s = size(in);
out = cell2mat(squeeze(cellfun(@(P) P(:), num2cell(in, 2),'uniform', 0)));
whos out
Más respuestas (0)
Ver también
Categorías
				Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


