How to create database to store extracted values?

6 ビュー (過去 30 日間)
Elias Unk
Elias Unk 2017 年 6 月 19 日
回答済み: Jaynik 2024 年 11 月 8 日 5:51
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 Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by