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."
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Cris LaPierre
on 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
0 Comments
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!