Changing Cell Array Dimension
이전 댓글 표시
Please I have a cell array as below but need it to be in 2 dimension, that is m-by-n instead of m-by-n-by-p.
segmented_images =
Columns 1 through 3
[2592x4608x3 unit8] [2592x4608x3 unit8] [2592x4608x3 unit8]
Columns 4 through 6
[2592x4608x3 unit8] [2592x4608x3 unit8] [2592x4608x3 unit8]
Thank you.
채택된 답변
추가 답변 (1개)
Image Analyst
2014년 9월 19일
What you said makes no sense. It's a 1D cell array. You can reshape it into a 2D array with reshape
segmented_images = reshape(segmented_images, [m,n]);
Saying "m-by-n instead of m-by-n-by-p." is nonsense because, like I said, the cell array is 1 by 6 not "m-by-n-by-p". The contents of a cell array are independent of the dimensions of the cell array itself. Think of a cell array as an array of buckets, with each cell being one bucket. Now you can thrown whatever you want into any of the buckets: strings, 2D or 3D arrays, structures, tables, or whatever you want, but that doesn't affect the arrangement of the buckets (how many buckets there are or how many rows or columns of buckets there are). See the FAQ for a better explanation. http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
댓글 수: 4
Image Analyst
2014년 9월 19일
By the way, why is this tagged with "color segmentation"? I have demos for that in my File Exchange if you're interested: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
bayoishola20
2014년 9월 20일
편집: bayoishola20
2014년 9월 20일
Image Analyst
2014년 9월 20일
I don't have the Statistics Toolbox so I can't run kmeans.
bayoishola20
2014년 9월 20일
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!