How to convert 2D array to a comma separated list of array
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
RuiQi
el 17 de En. de 2017
Respondida: Walter Roberson
el 17 de En. de 2017
regions = regionprops(label, image(:,:,1), 'Centroid');
regions(:).Centroid gives me a comma-separated-lists of vectors. How can I convert a 2D array into a comma-separated-list-of-vectors ? Below example I want to concatenate mean rgb data into region(:).MeanIntensity
r_data = regionprops(label, image(:,:,1), 'PixelValues', 'MeanIntensity');
g_data = regionprops(label, image(:,:,2), 'PixelValues', 'MeanIntensity');
b_data = regionprops(label, image(:,:,3), 'PixelValues', 'MeanIntensity');
I went to concatenate the data to get a 100 x 3 matrix
rgb = [vertcat(r_data(:).MeanIntensity), vertcat(g_data.MeanIntensity), vertcat(b_data.MeanIntensity)]
Now my task is to figure out how to push this into regions(:).RGB. Why does this not work ?
regions(:).MeanIntensity = [rgb(:,1), rgb(:,2), rgb(:,3)];
How do I tell Matlab to convert my 2D array of 100x3 into a comma separated list of vector
0 comentarios
Respuesta aceptada
Walter Roberson
el 17 de En. de 2017
rgbcell = mat2cell(rgb, ones(1, size(rgb,1)), size(rgb,2));
[regions(:).MeanIntensity] = rgbcell{:};
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Resizing and Reshaping 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!