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 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Cris LaPierre
Cris LaPierre il 3 Mar 2021
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

Categorie

Scopri di più su Tables in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by