I want to make an array/matrix of the features extracted of 10 images using detectSURFFeatures. How can I do this?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Subhadeep Koley
2020-1-9
编辑:Subhadeep Koley
2020-1-9
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!