How do I turn this 4x1 table to 60x1? It says "To assign to or create a variable in a table, the number of rows must match the height of the table."

2 ビュー (過去 30 日間)
srcFile=dir('C:\Users\arimu\OneDrive\Desktop\Training BMP\*.bmp');
for n=1:length(srcFile)
filename=strcat('C:\Users\arimu\OneDrive\Desktop\Training BMP\', srcFile(n).name);
I=imread(filename);
b=imresize(I,[100 100]);
c=rgb2gray(b);
d=imadjust(c);
level=graythresh(d);
e = imbinarize(d,level);
piccomp = imcomplement(e);
se = strel('square',4);
f = imdilate(piccomp,se);
g = imerode(f,se);
h = imclearborder(g,4);
i = imfill(h,'holes');
s = regionprops(i,'Area')
t(n,1)=struct2table(s)
end

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 3 月 3 日
You are trying to assing a table to a single element, resulting in the image. Perhaps you want to concatenate the tables on top of each other?
Try this instead.
srcFile=dir('C:\Users\arimu\OneDrive\Desktop\Training BMP\*.bmp');
% create an empty table
t=table;
for n=1:length(srcFile)
filename=strcat('C:\Users\arimu\OneDrive\Desktop\Training BMP\', srcFile(n).name);
I=imread(filename);
b=imresize(I,[100 100]);
c=rgb2gray(b);
d=imadjust(c);
level=graythresh(d);
e = imbinarize(d,level);
piccomp = imcomplement(e);
se = strel('square',4);
f = imdilate(piccomp,se);
g = imerode(f,se);
h = imclearborder(g,4);
i = imfill(h,'holes');
s = regionprops(i,'Area')
% append each table to the bottom of the existing table
t=[t;struct2table(s)]
end

カテゴリ

Help Center および File ExchangeTables についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by