retrieveImages giving empty scores
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
I am using retrieveImages on self-created data set (with limited number of images) for similar image retrieval of one object but I am getting empty scores and imageIDs. Can anyone answer why is it happening so ?
Respuestas (1)
  Hitesh
      
 el 7 de Mzo. de 2025
        Hi Neha,
I am assuming that you have sufficiently large and diverse image dataset that allow for effective similarity comparisons.Kindly ensure that the feature extraction step is working correctly. If the features are not extracted properly, the retrieval system won't be able to compare images effectively.
For a better understanding of similar image scores, refer to the following example and comments. In this example, I used Euclidean distance to compute similarity scores, employing a simple color histogram from the HSV color space as the feature. For better performance, consider using deep learning-based features.
% Define the path to your image dataset
imageFolder = 'sample_images';
imageFiles = dir(fullfile(imageFolder, '*.jpg')); % Adjust the extension as needed
% Initialize a cell array to store image features
imageFeatures = cell(length(imageFiles), 1);
% Loop through each image and extract features
for i = 1:length(imageFiles)
    % Read image
    img = imread(fullfile(imageFolder, imageFiles(i).name));
    % Convert to HSV color space and extract color histogram
    hsvImg = rgb2hsv(img);
    histFeatures = histcounts(hsvImg(:,:,1), 256); % Histogram for the hue channel
    % Normalize the histogram
    histFeatures = histFeatures / sum(histFeatures);
    % Store the features
    imageFeatures{i} = histFeatures;
end
% Example: Retrieve similar images for a query image
queryImage = imread('image.jpg');
queryHSV = rgb2hsv(queryImage);
queryHist = histcounts(queryHSV(:,:,1), 256);
queryHist = queryHist / sum(queryHist);
% Compute similarity scores (e.g., Euclidean distance)
scores = zeros(length(imageFiles), 1);
for i = 1:length(imageFiles)
    scores(i) = norm(queryHist - imageFeatures{i});
end
% Sort scores to find the most similar images
[sortedScores, sortedIndices] = sort(scores);
% Display the top 5 similar images
figure;
for i = 1:5
    subplot(1, 5, i);
    img = imread(fullfile(imageFolder, imageFiles(sortedIndices(i)).name));
    imshow(img);
    title(sprintf('Score: %.2f', sortedScores(i)));
end
For more information regarding "rgb2hsv", kindly refero to the following MATLAB documentation:
0 comentarios
Ver también
Categorías
				Más información sobre Image Processing and Computer Vision 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!


