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

조회 수: 1 (최근 30일)
Braiki Marwa
Braiki Marwa 2018년 1월 9일
편집: Braiki Marwa 2018년 1월 9일
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 :

답변 (1개)

KSSV
KSSV 2018년 1월 9일
You can save all the data into a single .mat file.....with different variable names.
  댓글 수: 4
Stephen23
Stephen23 2018년 1월 9일
"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 2018년 1월 9일
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');

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by