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.

回答(1 个)

Jaynik
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!

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by