I want to make an array/matrix of the features extracted of 10 images using detectSURFFeatures. How can I do this?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This is the code I have.
for i=1:10
num = i;
num_s = num2str(num);
extension = '.bmp';
filename = [num_s extension];
cereal_img = imread(filename);
cereal_img_grey = rgb2gray(cereal_img);
ref_pts = detectSURFFeatures(cereal_img_grey);
[ref_features, ref_validPts] = extractFeatures(cereal_img_grey, ref_pts);
[s1,s2]=size(ref_features);
S=s1*s2;
ftr=reshape(ref_features,1,S);
ref_array(i,:)=ftr;
end
However it is not working. It shows this error:
Unable to perform assignment because the size of the left side is
1-by-49664 and the size of the right side is 1-by-56512.
Error in cereal_array (line 18)
ref_array(i,:)=ftr;
0 commentaires
Réponses (1)
Subhadeep Koley
le 9 Jan 2020
Modifié(e) : Subhadeep Koley
le 9 Jan 2020
Saving extracted SURF features in array/matrix is difficult as, the number of extracted features is different for different images. You’re getting this error because the function extractFeatures is extracting features of different dimensions for different images.
As a workaround, you can save them in a cell array very easily. Refer the code below.
ref_array={}; % Declare a blank cell array
for i=1:10
num = i;
num_s = num2str(num);
extension = '.bmp';
filename = [num_s extension];
cereal_img = imread(filename);
cereal_img_grey = rgb2gray(cereal_img);
ref_pts = detectSURFFeatures(cereal_img_grey);
[ref_features, ref_validPts] = extractFeatures(cereal_img_grey, ref_pts);
[s1,s2]=size(ref_features);
S=s1*s2;
ftr=reshape(ref_features,1,S);
ref_array{i}=ftr; % Access each cell via the looping variable 'i'
end
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!