How to create database to store extracted values?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Jaynik
el 8 de Nov. de 2024 a las 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 comentarios
Ver también
Categorías
Más información sobre Database Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!