I want to make an array/matrix of the features extracted of 10 images using detectSURFFeatures. How can I do this?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Subhadeep Koley
il 9 Gen 2020
Modificato: Subhadeep Koley
il 9 Gen 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 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!