How can i save a single .mat file of features for many images (loop for)?

1 visualización (últimos 30 días)
i trained two-class-classification (svmtrain) with 15 features for 18 images and i have different number of objects in a single image. I want to save single .mat file of features of these images?my problem is when i run this code i have just the variables of last image!!This is my code :

Respuestas (1)

KSSV
KSSV el 9 de En. de 2018
You can save all the data into a single .mat file.....with different variable names.
  4 comentarios
Stephen23
Stephen23 el 9 de En. de 2018
"with different variable names."
Better would be to use one array, e.g. a cell array or an ND numeric array.
Braiki Marwa
Braiki Marwa el 9 de En. de 2018
This is my code :
NbIm = size(names1,1);
n1 = 1;
n2 = NbIm;
for n=n1:n2
%1- Read the original image
%2- Processing : Segmentation
%3- characterization :
[B3,L3,N3] = bwboundaries(ICellules); (see picture)
CC = bwconncomp(L3);
BW=bwlabel(L3); stats1=regionprops(CC,'Area','Centroid','Eccentricity','Perimeter','ConvexArea','ConvexHull','ConvexImage','MajorAxisLength','MinorAxisLength','Orientation','Solidity','BoundingBox');
for k=1:length(B3),
V=[];glcm=[];
V=Im_originale(BW==k);
glcm = graycomatrix(V,'Offset',[2 0],'Symmetric', true);
stats= graycoprops(glcm);
Contrast_Cellule =stats.Contrast;
Correlation_Cellule =stats.Correlation;
Energy_Cellule =stats.Energy;
Homogeneity_Cellule =stats.Homogeneity;
Area_cellule = stats1(k).Area;
Perimeter_cellule = stats1(k).Perimeter;
Circularity_cellule= (4*pi*Area_cellule)/Perimeter_cellule^2;
Centroid_cellule = stats1(k).Centroid;
Compactness_cellule=Perimeter_cellule^2/(4*pi*Area_cellule);
MajorAxis_cellule=stats1(k). MajorAxisLength;
MinorAxis_cellule=stats1(k). MinorAxisLength;
Orientation_cellule =stats1(k).Orientation;
Eccentricity_cellule=stats1(k).Eccentricity;
Solidity_cellule=stats1(k).Solidity;
boundary3 = B3{k};
[cc] = chaincode(boundary3);
ai=cc.code;
ai = ai.';
output = calc_harmonic_coefficients(ai,30);
Ampl=0.5*sqrt((output(1)^2)+(output(2)^2)+(output(3)^2)+(output(4)^2));
Feat(k,:)=[Area_cellule,Perimeter_cellule,Circularity_cellule,Compactness_cellule, Solidity_cellule,Eccentricity_cellule,MajorAxis_cellule,MinorAxis_cellule, Centroid_cellule,Ampl,Contrast_Cellule,Correlation_Cellule,Energy_Cellule,Homogeneity_Cellule];
end
end
save('FeatTrain.mat', 'Feat');

Iniciar sesión para comentar.

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by