How to create database to store extracted values?
6 ビュー (過去 30 日間)
古いコメントを表示
I have extracted 110 features of an image and input them in a features vector A:
A=[f1,f2,f3,f4....,f110];
How can i create a function that'll take a folder path as input and extract the features of every image and place it in a file to create a matrix of feature vectors of each sample , each row represent the parameters of a different sample and each column represent a different feature. Note that'll need to call those vectors back from the database in the main code.
0 件のコメント
回答 (1 件)
Jaynik
2024 年 11 月 8 日 5:51
Hi Elias,
Following is a sample function that you can use for creating a '.mat' file of features. You will need to change it based on your requirements.
function createFeatureDatabase(folderPath, outputFile)
% Get list of all image files in the folder
imageFiles = dir(fullfile(folderPath, '*.jpg')); % Adjust the extension as needed
numImages = length(imageFiles);
% Initialize an empty matrix to store features
featureMatrix = [];
for i = 1:numImages
img = imread(fullfile(folderPath, imageFiles(i).name));
% Extract features (replace this with your actual feature extraction code)
features = extractFeatures(img);
% Append the features to the feature matrix
featureMatrix = [featureMatrix; features];
end
% Save the feature matrix to a file
save(outputFile, 'featureMatrix');
end
createFeatureDatabase('path/to/your/folder', 'featureDatabase.mat');
To load the feature matrix and create the database:
load('featureDatabase.mat', 'featureMatrix');
Hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Database Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!