Create a struct that contain ABCD features for an image dataset

2 views (last 30 days)
Hello guys, I've been trying to import the ABCD features of all my image dataset but when I open the csv file I only find one row and I don't know how I can fix it
imds = imageDatastore(Source,"IncludeSubfolders",true,"FileExtensions",".jpg");
imds1 = imageDatastore(Source1,"IncludeSubfolders",true,"FileExtensions",".jpg");
% lire toutes les images avec une boucle
for i= 1 :size(imds.Files,1)
I = readimage(imds,i);
gray=rgb2gray(I);
binaryImage=imbinarize(rescale(gray));
binaryImage = bwareafilt(binaryImage, 1);
segmented=readimage(imds1,i);
asymmetry=ASYMMETRY(binaryImage,segmented);
Colors_Score=Couleur(segmented);
Borders=borders(binaryImage);
Diameter=diameter(binaryImage);
ABCD_Features.Asymmetry1=asymmetry.A1;
ABCD_Features.Asymmetry2=asymmetry.A2;
ABCD_Features.Color=Colors_Score;
ABCD_Features.Border1=Borders.B1;
ABCD_Features.Border2=Borders.B2;
ABCD_Features.Border3=Borders.B3;
ABCD_Features.Diameter1=Diameter.D1;
ABCD_Features.Diameter2=Diameter.D2;
ABCD_Features=struct2table(ABCD_Features);
writetable( ABCD_Features, 'ABCD_Features.csv');
end
ASYMMETRY, Couleur, Borders and diamter are my functions that I use, I will be very grateful if you can help me with this

Accepted Answer

Image Analyst
Image Analyst on 12 May 2022
You need to tack on that table to a growing one.
imds = imageDatastore(Source,"IncludeSubfolders",true,"FileExtensions",".jpg");
imds1 = imageDatastore(Source1,"IncludeSubfolders",true,"FileExtensions",".jpg");
% lire toutes les images avec une boucle
for i= 1 :size(imds.Files,1)
I = readimage(imds,i);
gray=rgb2gray(I);
binaryImage=imbinarize(rescale(gray));
binaryImage = bwareafilt(binaryImage, 1);
segmented=readimage(imds1,i);
asymmetry=ASYMMETRY(binaryImage,segmented);
Colors_Score=Couleur(segmented);
Borders=borders(binaryImage);
Diameter=diameter(binaryImage);
ABCD_Features.Asymmetry1=asymmetry.A1;
ABCD_Features.Asymmetry2=asymmetry.A2;
ABCD_Features.Color=Colors_Score;
ABCD_Features.Border1=Borders.B1;
ABCD_Features.Border2=Borders.B2;
ABCD_Features.Border3=Borders.B3;
ABCD_Features.Diameter1=Diameter.D1;
ABCD_Features.Diameter2=Diameter.D2;
thisTable = struct2table(ABCD_Features);
% Add this table on to our growing, master table.
if i == 1
masterTable = thisTable;
else
masterTable = [masterTable; thisTable];
end
end
% Write out master table.
writetable( ABCD_Features, 'ABCD_Features.csv');
It's untested so it might need some debugging.

More Answers (0)

Categories

Find more on Data Import and Analysis 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!