how to make a perfect table
조회 수: 3 (최근 30일)
이전 댓글 표시
hi. i wanted to descripe some info of a pic as a table. but i have some problems here.
1- i dont want number in braket. for example i want [1] change to 1
2- how can i show the info of Centroid and BoundingBox columns?
3-how can i put borders for the table?
clear;
I = imread('rice.png');
bw=imbinarize(I);
[labeled,numobjects]=bwlabel(bw,4);
numobjects;
labeledprops=regionprops(labeled,'basic');
for i=1:numobjects
row{i}=i;
area{i}=labeledprops(i).Area;
centroid{i}=labeledprops(i).Centroid;
boundingbox{i}=labeledprops(i).BoundingBox;
end
C_row=row';C_area=area';C_centroid=centroid';C_boundingbox=boundingbox';
T = table(C_row,C_area,C_centroid,C_boundingbox)
T.Properties.VariableNames = {'row' 'Area' 'Centroid' 'BoundingBox'}
![table.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/251618/table.jpeg)
댓글 수: 0
채택된 답변
Adam Danz
2019년 11월 30일
편집: Adam Danz
2019년 11월 30일
The idea is to convert your cell arrays to tall matrices or column vectors. That could be done prior to entering the values into table() or it can be done as you enter the values into table() (shown below).
T = table([C_row{:}].',[C_area{:}].',cell2mat(C_centroid),cell2mat(C_boundingbox));
T.Properties.VariableNames = {'row' 'Area' 'Centroid' 'BoundingBox'}
View results
head(T)
ans =
8×4 table
row Area Centroid BoundingBox
___ ____ ________________ ______________________________
1 145 5.9448 35.028 0.5 21.5 13 23
2 127 6.4803 62.087 0.5 52.5 13 17
3 71 2.1408 85.099 0.5 72.5 4 24
4 187 4.615 117.65 0.5 102.5 10 29
5 160 9.4563 141.29 0.5 132.5 20 16
6 86 4.0581 179.23 0.5 170.5 8 15
7 182 11.758 205.15 0.5 199.5 23 11
8 60 6.3833 222.33 0.5 218.5 15 9
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!