How to convert 2D array to a comma separated list of array
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
RuiQi
am 17 Jan. 2017
Beantwortet: Walter Roberson
am 17 Jan. 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 17 Jan. 2017
rgbcell = mat2cell(rgb, ones(1, size(rgb,1)), size(rgb,2));
[regions(:).MeanIntensity] = rgbcell{:};
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!